core.generator.generic #
generation framework
#hero generate -p thepath_is_optional
##hero generate -p thepath_is_optional -t client
#hero generate -p thepath_is_optional -t installer
#hero generate -p thepath_is_optional -t installer -s
there will be a .heroscript
in the director you want to generate for, the format is as follows:
//for a server
!!hero_code.generate_installer
name:'daguserver'
classname:'DaguServer'
singleton:1 //there can only be 1 object in the globals, is called 'default'
templates:1 //are there templates for the installer
default:1 //can we create a default when the factory is used
title:''
supported_platforms:'' //osx, ... (empty means all)
reset:0 // regenerate all, dangerous !!!
startupmanager:1 //managed by a startup manager, default true
build:1 //will we also build the component
//or for a client
!!hero_code.generate_client
name:'mail'
classname:'MailClient'
singleton:0 //default is 0
default:1 //can we create a default when the factory is used
reset:0 // regenerate all, dangerous !!!
needs to be put as .heroscript in the directories which we want to generate
templates remarks
in templates:
- ^^ or @@ > gets replaced to @
- ?? > gets replaced to $
this is to make distinction between processing at compile time (pre-compile) or at runtime.
call by code
to call in code
import freeflowuniverse.crystallib.core.generator.installer
installer.scan('~/github/freeflowuniverse/crystallib/crystallib')!
fn create_heroscript #
fn create_heroscript(args GeneratorArgs) !
fn generate #
fn generate(args_ GeneratorArgs) !
will ask questions when not in force mode & generate the module
fn scan #
fn scan(args_ GeneratorArgs) !
scan over a set of directories call the play where
enum Cat #
enum Cat {
installer
client
}
struct GeneratorArgs #
struct GeneratorArgs {
pub mut:
name string
classname string
default bool = true // means user can just get the object and a default will be created
title string
supported_platforms []string // only relevant for installers for now
singleton bool // means there can only be one
templates bool // means we will use templates in the installer, client doesn't do this'
reset bool // regenerate all, dangerous !!!
startupmanager bool = true
build bool
cat Cat
path string
force bool
hasconfig bool = true
}
fn (GeneratorArgs) platform_check_str #
fn (args GeneratorArgs) platform_check_str() string