generation starts working again
This commit is contained in:
@@ -13,6 +13,7 @@ fp.skip_executable()
|
||||
mut path := fp.string('path', `p`, "", 'Path where to generate a module, if not mentioned will scan over all installers & clients.\nif . then will be path we are on.')
|
||||
reset := fp.bool('reset', `r`, false, 'If we want to reset')
|
||||
interactive := fp.bool('interactive', `i`, true, 'If we want to work interactive')
|
||||
scan := fp.bool('scan', `s`, false, 'If we want to scan')
|
||||
help_requested := fp.bool('help', `h`, false, 'Show help message')
|
||||
|
||||
if help_requested {
|
||||
@@ -36,11 +37,13 @@ if additional_args.len > 0 {
|
||||
// interactive bool //if we want to ask
|
||||
// path string
|
||||
|
||||
|
||||
|
||||
if path.trim_space() == "." {
|
||||
path = os.getwd()
|
||||
path = os.getwd()
|
||||
}
|
||||
|
||||
if path {
|
||||
if ! scan {
|
||||
generator.do(path:path, reset:reset, interactive:interactive)!
|
||||
}else{
|
||||
generator.scan(path:path, reset:reset, interactive:interactive)!
|
||||
|
||||
32
lib/clients/mycelium/mycelium_factory_.v
Normal file
32
lib/clients/mycelium/mycelium_factory_.v
Normal file
@@ -0,0 +1,32 @@
|
||||
|
||||
module mycelium
|
||||
|
||||
import freeflowuniverse.herolib.core.base
|
||||
import freeflowuniverse.herolib.core.playbook
|
||||
import freeflowuniverse.herolib.ui.console
|
||||
|
||||
|
||||
__global (
|
||||
mycelium_global map[string]&Mycelium
|
||||
mycelium_default string
|
||||
)
|
||||
|
||||
/////////FACTORY
|
||||
|
||||
@[params]
|
||||
pub struct ArgsGet{
|
||||
pub mut:
|
||||
name string
|
||||
}
|
||||
|
||||
pub fn get(args_ ArgsGet) !&Mycelium {
|
||||
return &Mycelium{}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//switch instance to be used for mycelium
|
||||
pub fn switch(name string) {
|
||||
mycelium_default = name
|
||||
}
|
||||
32
lib/clients/mycelium/mycelium_model.v
Normal file
32
lib/clients/mycelium/mycelium_model.v
Normal file
@@ -0,0 +1,32 @@
|
||||
module mycelium
|
||||
import freeflowuniverse.herolib.data.paramsparser
|
||||
import os
|
||||
|
||||
pub const version = '1.14.3'
|
||||
const singleton = true
|
||||
const default = true
|
||||
|
||||
|
||||
//THIS THE THE SOURCE OF THE INFORMATION OF THIS FILE, HERE WE HAVE THE CONFIG OBJECT CONFIGURED AND MODELLED
|
||||
|
||||
$[heap]
|
||||
pub struct Mycelium {
|
||||
pub mut:
|
||||
name string = 'default'
|
||||
mail_from string
|
||||
mail_password string @[secret]
|
||||
mail_port int
|
||||
mail_server string
|
||||
mail_username string
|
||||
}
|
||||
|
||||
|
||||
|
||||
fn obj_init(obj_ Mycelium)!Mycelium{
|
||||
//never call get here, only thing we can do here is work on object itself
|
||||
mut obj:=obj_
|
||||
return obj
|
||||
}
|
||||
|
||||
|
||||
|
||||
30
lib/clients/mycelium/readme.md
Normal file
30
lib/clients/mycelium/readme.md
Normal file
@@ -0,0 +1,30 @@
|
||||
# mycelium
|
||||
|
||||
|
|
||||
|
||||
To get started
|
||||
|
||||
```vlang
|
||||
|
||||
|
||||
import freeflowuniverse.herolib.clients. mycelium
|
||||
|
||||
mut client:= mycelium.get()!
|
||||
|
||||
client...
|
||||
|
||||
|
||||
|
||||
|
||||
```
|
||||
|
||||
## example heroscript
|
||||
|
||||
```hero
|
||||
!!mycelium.configure
|
||||
secret: '...'
|
||||
host: 'localhost'
|
||||
port: 8888
|
||||
```
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ import freeflowuniverse.herolib.core.pathlib
|
||||
pub fn ask(path string) ! {
|
||||
mut myconsole := console.new()
|
||||
|
||||
mut model:= gen_model_get(path)!
|
||||
mut model:= gen_model_get(path, false)!
|
||||
|
||||
console.clear()
|
||||
console.print_header('Configure generation of code for a module on path:')
|
||||
|
||||
@@ -33,7 +33,7 @@ pub fn do(args_ GenerateArgs) ! {
|
||||
if args.path == '' {
|
||||
args.path = os.getwd()
|
||||
}
|
||||
mut m := gen_model_get(args.path,create:false)!
|
||||
mut m := gen_model_get(args.path, false)!
|
||||
m
|
||||
}
|
||||
|
||||
@@ -56,7 +56,7 @@ pub fn do(args_ GenerateArgs) ! {
|
||||
|
||||
if args.interactive{
|
||||
ask(args.path)!
|
||||
args.model = gen_model_get(args.path)!
|
||||
args.model = gen_model_get(args.path, false)!
|
||||
}
|
||||
|
||||
console.print_debug(args)
|
||||
|
||||
@@ -43,7 +43,7 @@ fn generate(args GenerateArgs) ! {
|
||||
if args.reset {
|
||||
path_templ_dir.delete()!
|
||||
}
|
||||
if args.model.templates {
|
||||
if (args.model or { panic('bug') }).templates {
|
||||
if !path_templ_dir.exists() {
|
||||
mut templ_6 := $tmpl('templates/atemplate.yaml')
|
||||
pathlib.template_write(templ_6, '${args.path}/templates/atemplate.yaml', true)!
|
||||
|
||||
@@ -33,12 +33,13 @@ pub enum Cat {
|
||||
|
||||
|
||||
pub fn gen_model_set(args GenerateArgs) ! {
|
||||
model := args.model
|
||||
mut heroscript_templ := match model.cat {
|
||||
.client { heroscript_templ := $tmpl('templates/heroscript_client' )}
|
||||
.installer { heroscript_templ := $tmpl('templates/heroscript_installer' )}
|
||||
model := args.model or { return error('model is none') }
|
||||
heroscript_templ := match model.cat {
|
||||
.client { $tmpl('templates/heroscript_client') }
|
||||
.installer { $tmpl('templates/heroscript_installer') }
|
||||
else { return error('Invalid category: ${model.cat}') }
|
||||
}
|
||||
|
||||
pathlib.template_write(heroscript_templ, '${args.path}/.heroscript', true)!
|
||||
}
|
||||
|
||||
|
||||
@@ -16,8 +16,8 @@ pub mut:
|
||||
pub fn scan(args ScannerArgs) ! {
|
||||
|
||||
if args.path == "" {
|
||||
scan(path:"${os.home_dir()}/code/github/freeflowuniverse/herolib/lib/installers")
|
||||
scan(path:"${os.home_dir()}/code/github/freeflowuniverse/herolib/lib/clients")
|
||||
scan(path:"${os.home_dir()}/code/github/freeflowuniverse/herolib/lib/installers")!
|
||||
scan(path:"${os.home_dir()}/code/github/freeflowuniverse/herolib/lib/clients")!
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user