diff --git a/generate.vsh b/generate.vsh index 20acdf04..1015db01 100755 --- a/generate.vsh +++ b/generate.vsh @@ -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)! diff --git a/lib/clients/mycelium/mycelium_factory_.v b/lib/clients/mycelium/mycelium_factory_.v new file mode 100644 index 00000000..9052f281 --- /dev/null +++ b/lib/clients/mycelium/mycelium_factory_.v @@ -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 +} diff --git a/lib/clients/mycelium/mycelium_model.v b/lib/clients/mycelium/mycelium_model.v new file mode 100644 index 00000000..b769af09 --- /dev/null +++ b/lib/clients/mycelium/mycelium_model.v @@ -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 +} + + + diff --git a/lib/clients/mycelium/readme.md b/lib/clients/mycelium/readme.md new file mode 100644 index 00000000..836e9a2b --- /dev/null +++ b/lib/clients/mycelium/readme.md @@ -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 +``` + + diff --git a/lib/code/generator/installer_client/ask.v b/lib/code/generator/installer_client/ask.v index 429999aa..c82cffcd 100644 --- a/lib/code/generator/installer_client/ask.v +++ b/lib/code/generator/installer_client/ask.v @@ -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:') diff --git a/lib/code/generator/installer_client/factory.v b/lib/code/generator/installer_client/factory.v index ebd04259..8181e421 100644 --- a/lib/code/generator/installer_client/factory.v +++ b/lib/code/generator/installer_client/factory.v @@ -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) diff --git a/lib/code/generator/installer_client/generate.v b/lib/code/generator/installer_client/generate.v index 579458bb..253079fc 100644 --- a/lib/code/generator/installer_client/generate.v +++ b/lib/code/generator/installer_client/generate.v @@ -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)! diff --git a/lib/code/generator/installer_client/model.v b/lib/code/generator/installer_client/model.v index ceedc79a..a419e562 100644 --- a/lib/code/generator/installer_client/model.v +++ b/lib/code/generator/installer_client/model.v @@ -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)! } diff --git a/lib/code/generator/installer_client/scanner.v b/lib/code/generator/installer_client/scanner.v index 3de34481..33e57329 100644 --- a/lib/code/generator/installer_client/scanner.v +++ b/lib/code/generator/installer_client/scanner.v @@ -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 }