Skip to content

code.generator.installer_client #

generation framework for clients & installers

#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
    title:''
    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

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

#!/usr/bin/env -S v -gc none  -cc tcc -d use_openssl -enable-globals run

import freeflowuniverse.herolib.code.generator.generic

generic.scan(path:"~/code/github/freeflowuniverse/herolib/herolib/installers",force:true)!


to run from bash

~/code/github/freeflowuniverse/herolib/scripts/fix_installers.vsh

fn ask #

fn ask(path string) !

will ask questions & create the .heroscript

fn do #

fn do(args_ GenerateArgs) !

the default to start with

reset bool // regenerate all, dangerous !!! interactive bool //if we want to ask path string model ?GenModel cat ?Cat

fn gen_model_get #

fn gen_model_get(path string, create bool) !GenModel

loads the heroscript and return the model

fn gen_model_set #

fn gen_model_set(args GenerateArgs) !

creates the heroscript from the GenModel as part of GenerateArgs

fn scan #

fn scan(args ScannerArgs) !

scan over a set of directories call the play where

enum Cat #

enum Cat {
	unknown
	client
	installer
}

struct GenModel #

struct GenModel {
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 !!!
	interactive    bool // if we want to ask
	startupmanager bool = true
	build          bool = true
	hasconfig      bool = true
	cat            Cat // dont' set default
}

struct GenerateArgs #

@[params]
struct GenerateArgs {
pub mut:
	reset       bool // regenerate all, dangerous !!!
	interactive bool // if we want to ask
	path        string
	model       ?GenModel
	cat         ?Cat
}

struct ScannerArgs #

@[params]
struct ScannerArgs {
pub mut:
	reset       bool // regenerate all, dangerous !!!
	interactive bool // if we want to ask
	path        string
}