...
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
#!/usr/bin/env -S v -n -w -gc none -cc tcc -d use_openssl -enable-globals run
|
#!/usr/bin/env -S v -n -w -gc none -cc tcc -d use_openssl -enable-globals run
|
||||||
|
|
||||||
import freeflowuniverse.herolib.core.generator.installer
|
import freeflowuniverse.herolib.core.generator.generic as generator
|
||||||
|
|
||||||
installer.scan('~/code/github/freeflowuniverse/herolib/herolib')!
|
|
||||||
|
generic.scan(path:"~/code/github/freeflowuniverse/herolib/herolib/installers",force:true)!
|
||||||
|
|||||||
@@ -13,9 +13,6 @@ const action_priorities = {
|
|||||||
|
|
||||||
|
|
||||||
pub fn play(mut plbook PlayBook) ! {
|
pub fn play(mut plbook PlayBook) ! {
|
||||||
mut plbook := args.plbook or {
|
|
||||||
playbook.new(text: args.heroscript, path: args.heroscript_path)!
|
|
||||||
}
|
|
||||||
|
|
||||||
// group actions by which bizmodel they belong to
|
// group actions by which bizmodel they belong to
|
||||||
actions_by_biz := arrays.group_by[string, &Action](plbook.actions_find(actor: 'bizmodel')!,
|
actions_by_biz := arrays.group_by[string, &Action](plbook.actions_find(actor: 'bizmodel')!,
|
||||||
|
|||||||
@@ -5,10 +5,6 @@ import freeflowuniverse.herolib.core.playbook {PlayBook}
|
|||||||
import freeflowuniverse.herolib.ui.console
|
import freeflowuniverse.herolib.ui.console
|
||||||
|
|
||||||
fn play_git(mut plbook PlayBook) ! {
|
fn play_git(mut plbook PlayBook) ! {
|
||||||
mut args := args_
|
|
||||||
mut plbook := args.plbook or {
|
|
||||||
playbook.new(text: args.heroscript, path: args.heroscript_path)!
|
|
||||||
}
|
|
||||||
|
|
||||||
// Handle !!git.define action first to configure GitStructure
|
// Handle !!git.define action first to configure GitStructure
|
||||||
define_actions := plbook.find(filter: 'git.define')!
|
define_actions := plbook.find(filter: 'git.define')!
|
||||||
|
|||||||
@@ -1,20 +1,20 @@
|
|||||||
module playmacros
|
module playmacros
|
||||||
|
|
||||||
import freeflowuniverse.herolib.ui.console
|
import freeflowuniverse.herolib.ui.console
|
||||||
import freeflowuniverse.herolib.core.playbook
|
import freeflowuniverse.herolib.core.playbook {PlayBook, Action}
|
||||||
import freeflowuniverse.herolib.threefold.grid4.gridsimulator
|
import freeflowuniverse.herolib.threefold.grid4.gridsimulator
|
||||||
import freeflowuniverse.herolib.threefold.grid4.farmingsimulator
|
import freeflowuniverse.herolib.threefold.grid4.farmingsimulator
|
||||||
import freeflowuniverse.herolib.biz.bizmodel
|
import freeflowuniverse.herolib.biz.bizmodel
|
||||||
import freeflowuniverse.herolib.biz.spreadsheet
|
import freeflowuniverse.herolib.biz.spreadsheet
|
||||||
|
|
||||||
pub fn play_actions(mut plbook playbook.PlayBook) ! {
|
pub fn play_actions(mut plbook PlayBook) ! {
|
||||||
console.print_green('play actions (simulators)')
|
console.print_green('play actions (simulators)')
|
||||||
farmingsimulator.play(mut plbook)!
|
farmingsimulator.play(mut plbook)!
|
||||||
gridsimulator.play(mut plbook)!
|
gridsimulator.play(mut plbook)!
|
||||||
bizmodel.play(plbook: *plbook)!
|
bizmodel.play(mut plbook)!
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn play_macro(action playbook.Action) !string {
|
pub fn play_macro(action Action) !string {
|
||||||
if action.actiontype != .macro {
|
if action.actiontype != .macro {
|
||||||
panic('should always be a macro')
|
panic('should always be a macro')
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,105 +0,0 @@
|
|||||||
module mdbook
|
|
||||||
|
|
||||||
import freeflowuniverse.herolib.core.base
|
|
||||||
import freeflowuniverse.herolib.core.playbook
|
|
||||||
|
|
||||||
__global (
|
|
||||||
mdbook_global map[string]&MDBooks
|
|
||||||
mdbook_default string
|
|
||||||
)
|
|
||||||
|
|
||||||
/////////FACTORY
|
|
||||||
|
|
||||||
@[params]
|
|
||||||
pub struct ArgsGet {
|
|
||||||
pub mut:
|
|
||||||
name string = 'default'
|
|
||||||
}
|
|
||||||
|
|
||||||
fn args_get(args_ ArgsGet) ArgsGet {
|
|
||||||
mut args := args_
|
|
||||||
if args.name == '' {
|
|
||||||
args.name = mdbook_default
|
|
||||||
}
|
|
||||||
if args.name == '' {
|
|
||||||
args.name = 'default'
|
|
||||||
}
|
|
||||||
return args
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn get(args_ ArgsGet) !&MDBooks {
|
|
||||||
mut args := args_get(args_)
|
|
||||||
if args.name !in mdbook_global {
|
|
||||||
if !config_exists() {
|
|
||||||
if default {
|
|
||||||
config_save()!
|
|
||||||
}
|
|
||||||
}
|
|
||||||
config_load()!
|
|
||||||
}
|
|
||||||
return mdbook_global[args.name] or {
|
|
||||||
println(mdbook_global)
|
|
||||||
panic('bug in get from factory: ')
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn config_exists(args_ ArgsGet) bool {
|
|
||||||
mut args := args_get(args_)
|
|
||||||
mut context := base.context() or { panic('bug') }
|
|
||||||
return context.hero_config_exists('mdbook', args.name)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn config_load(args_ ArgsGet) ! {
|
|
||||||
mut args := args_get(args_)
|
|
||||||
mut context := base.context()!
|
|
||||||
mut heroscript := context.hero_config_get('mdbook', args.name)!
|
|
||||||
play(heroscript: heroscript)!
|
|
||||||
}
|
|
||||||
|
|
||||||
fn config_save(args_ ArgsGet) ! {
|
|
||||||
mut args := args_get(args_)
|
|
||||||
mut context := base.context()!
|
|
||||||
context.hero_config_set('mdbook', args.name, heroscript_default()!)!
|
|
||||||
}
|
|
||||||
|
|
||||||
fn set(o MDBooks) ! {
|
|
||||||
mut o2 := obj_init(o)!
|
|
||||||
mdbook_global['default'] = &o2
|
|
||||||
}
|
|
||||||
|
|
||||||
@[params]
|
|
||||||
pub struct PlayArgs {
|
|
||||||
pub mut:
|
|
||||||
name string = 'default'
|
|
||||||
heroscript string // if filled in then plbook will be made out of it
|
|
||||||
plbook ?playbook.PlayBook
|
|
||||||
reset bool
|
|
||||||
|
|
||||||
start bool
|
|
||||||
stop bool
|
|
||||||
restart bool
|
|
||||||
delete bool
|
|
||||||
configure bool // make sure there is at least one installed
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn play(mut plbook PlayBook) ! {
|
|
||||||
mut args := args_
|
|
||||||
|
|
||||||
if args.heroscript == '' {
|
|
||||||
args.heroscript = heroscript_default()!
|
|
||||||
}
|
|
||||||
mut plbook := args.plbook or { playbook.new(text: args.heroscript)! }
|
|
||||||
|
|
||||||
mut install_actions := plbook.find(filter: 'mdbook.configure')!
|
|
||||||
if install_actions.len > 0 {
|
|
||||||
for install_action in install_actions {
|
|
||||||
mut p := install_action.params
|
|
||||||
cfg_play(p)!
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// switch instance to be used for mdbook
|
|
||||||
pub fn switch(name string) {
|
|
||||||
mdbook_default = name
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user