This commit is contained in:
2025-11-30 08:59:38 +01:00
parent 0963910572
commit 5b2069c560
32 changed files with 60 additions and 59 deletions

View File

@@ -10,6 +10,7 @@ fp.version('v0.1.0')
fp.description('Compile hero binary in debug or production mode')
fp.skip_executable()
prod_mode := fp.bool('prod', `p`, false, 'Build production version (optimized)')
help_requested := fp.bool('help', `h`, false, 'Show help message')
@@ -61,6 +62,8 @@ compile_cmd := if os.user_os() == 'macos' {
'v -enable-globals -g -w -n -prod hero.v'
} else {
'v -n -g -w -cg -gc none -cc tcc -d use_openssl -enable-globals hero.v'
// 'v -n -g -w -cg -gc none -cc tcc -d use_openssl -enable-globals hero.v'
// 'v -cg -enable-globals -parallel-cc -w -n -d use_openssl hero.v'
}
} else {
if prod_mode {

View File

@@ -13,7 +13,7 @@ import incubaid.herolib.installers.lang.python
import os
fn startupcmd() ![]startupmanager.ZProcessNewArgs {
mut installer := get()!
_ := get()!
mut res := []startupmanager.ZProcessNewArgs{}
// THIS IS EXAMPLE CODEAND NEEDS TO BE CHANGED
// res << startupmanager.ZProcessNewArgs{
@@ -28,7 +28,7 @@ fn startupcmd() ![]startupmanager.ZProcessNewArgs {
}
fn running() !bool {
mut installer := get()!
_ := get()!
// THIS IS EXAMPLE CODEAND NEEDS TO BE CHANGED
// this checks health of erpnext
// curl http://localhost:3333/api/v1/s --oauth2-bearer 1234 works

View File

@@ -16,7 +16,7 @@ pub mut:
pub fn (b BizModel) export(args ExportArgs) ! {
name := if args.name != '' { args.name } else { texttools.snake_case(args.title) }
path := pathlib.get_dir(
pathlib.get_dir(
path: os.join_path(os.home_dir(), 'hero/var/bizmodel/exports/${name}')
create: true
empty: true
@@ -52,7 +52,7 @@ pub fn (model BizModel) write_operational_plan(args ExportArgs) ! {
mut hr_page := pathlib.get_file(path: '${hr_dir.path}/human_resources.md')!
hr_page.template_write($tmpl('./templates/human_resources.md'), true)!
for key, employee in model.employees {
for _, employee in model.employees {
mut employee_page := pathlib.get_file(
path: '${hr_dir.path}/${texttools.snake_case(employee.name)}.md'
)!
@@ -73,7 +73,7 @@ pub fn (model BizModel) write_operational_plan(args ExportArgs) ! {
}
}
for key, department in model.departments {
for _, department in model.departments {
dept := department
mut dept_page := pathlib.get_file(
path: '${depts_dir.path}/${texttools.snake_case(department.name)}.md'
@@ -94,7 +94,7 @@ pub fn (model BizModel) write_revenue_model(args ExportArgs) ! {
products_page.template_write('# Products', true)!
name1 := 'example'
for key, product in model.products {
for _, product in model.products {
mut product_page := pathlib.get_file(
path: '${products_dir.path}/${texttools.snake_case(product.name)}.md'
)!

View File

@@ -7,7 +7,7 @@ import incubaid.herolib.core.pathlib
pub struct ExportCSVArgs {
pub mut:
path string
include_empty bool = false // whether to include empty cells or not
include_empty bool // whether to include empty cells or not
separator string = '|' // separator character for CSV
}

View File

@@ -22,7 +22,7 @@ pub fn play(mut plbook PlayBook) ! {
})
// play actions for each biz in plbook
for biz, actions in actions_by_biz {
for biz, _ in actions_by_biz {
mut model := getset(biz)!
model.play(mut plbook)!
}

View File

@@ -8,7 +8,7 @@ import incubaid.herolib.core.playbook { Action }
// title:'Engineering Division'
// avg_monthly_cost:'6000USD' avg_indexation:'5%'
fn (mut m BizModel) department_define_action(action Action) !Action {
bizname := action.params.get_default('bizname', '')!
_ := action.params.get_default('bizname', '')!
mut name := action.params.get('name') or { return error('department name is required') }
mut descr := action.params.get_default('descr', '')!
if descr.len == 0 {

View File

@@ -74,7 +74,7 @@ fn (mut m BizModel) employee_define_action(action Action) !Action {
mut curcost := -costpeople_row.cells[x].val
mut curpeople := nrpeople_row.cells[x].val
mut currev := revtotal.cells[x].val
// println("currev: ${currev}, curcost: ${curcost}, curpeople: ${curpeople}, costpercent_revenue: ${cost_percent_revenue}")
println("currev: ${currev}, curcost: ${curcost}, curpeople: ${curpeople}, costpercent_revenue: ${cost_percent_revenue}")
if currev * cost_percent_revenue > curcost {
costpeople_row.cells[x].val = -currev * cost_percent_revenue
nrpeople_row.cells[x].val = f64(currev * cost_percent_revenue / costperson_default.usd())

View File

@@ -10,7 +10,7 @@ fn (mut sim BizModel) pl_total() ! {
// sheet.pprint(nr_columns: 10)!
mut pl_total := sheet.group2row(
_ := sheet.group2row(
name: 'pl_summary'
include: ['pl']
tags: 'summary'

View File

@@ -77,7 +77,7 @@ fn (mut m BizModel) revenue_action(action Action) !Action {
product.has_revenue = true
}
mut margin := revenue.action(
_ := revenue.action(
name: '${r.name}_margin'
descr: 'Margin for ${r.name}'
action: .substract

View File

@@ -6,7 +6,7 @@ import incubaid.herolib.core.texttools
// see lib/biz/bizmodel/docs/revenue.md
fn (mut m BizModel) revenue_item_action(action Action) !Action {
mut r := get_action_descr(action)!
mut product := m.products[r.name]
mut product := m.products[r.name] or { return error('Product "${r.name}" not found for revenue item action') }
mut nr_sold := m.sheet.row_new(
name: '${r.name}_nr_sold'
@@ -193,7 +193,7 @@ fn (mut m BizModel) revenue_item_action(action Action) !Action {
tags: 'name:${r.name}'
)!
mut margin := margin_setup.action(
_ := margin_setup.action(
name: '${r.name}_margin'
descr: 'Margin for ${r.name}'
action: .add

View File

@@ -6,19 +6,19 @@ import incubaid.herolib.core.playbook
fn (mut sim BizModel) revenue_total() ! {
mut sheet := sim.sheet
mut revenue_total := sheet.group2row(
_ := sheet.group2row(
name: 'revenue_total'
include: ['rev']
tags: 'total revtotal pl'
descr: 'Revenue Total'
)!
mut cogs_total := sheet.group2row(
_ := sheet.group2row(
name: 'cogs_total'
include: ['cogs']
tags: 'total cogstotal pl'
descr: 'Cost of Goods Total.'
)!
mut margin_total := sheet.group2row(
_ := sheet.group2row(
name: 'margin_total'
include: ['margin']
tags: 'total margintotal'

View File

@@ -7,7 +7,7 @@ import incubaid.herolib.core.pathlib
pub struct ExportCSVArgs {
pub mut:
path string
include_empty bool = false // whether to include empty cells or not
include_empty bool // whether to include empty cells or not
separator string = '|' // separator character for CSV
}

View File

@@ -118,23 +118,23 @@ pub fn (s Sheet) data_get_as_string(args RowGetArgs) !string {
}
nryears := 5
err_pre := "Can't get data for sheet:${s.name} row:${args.rowname}.\n"
mut s2 := s
mut s2 := s
if args.period_type == .year {
s2 = s.toyear(
name: args.rowname
namefilter: args.namefilter
includefilter: args.includefilter
excludefilter: args.excludefilter
)!
s2 = *s.toyear(
name: args.rowname
namefilter: args.namefilter
includefilter: args.includefilter
excludefilter: args.excludefilter
)!
}
if args.period_type == .quarter {
s2 = s.toquarter(
name: args.rowname
namefilter: args.namefilter
includefilter: args.includefilter
excludefilter: args.excludefilter
)!
s2 = *s.toquarter(
name: args.rowname
namefilter: args.namefilter
includefilter: args.includefilter
excludefilter: args.excludefilter
)!
}
mut out := ''

View File

@@ -20,7 +20,7 @@ fn pad_right(s string, length int) string {
pub struct PPrintArgs {
pub mut:
group_months int = 1 // e.g. if 2 then will group by 2 months
nr_columns int = 0 // number of columns to show in the table, 0 is all
nr_columns int // number of columns to show in the table, 0 is all
description bool // show description in the table
aggrtype bool = true // show aggregate type in the table
tags bool = true // show tags in the table
@@ -151,7 +151,7 @@ pub fn (mut s Sheet) pprint(args PPrintArgs) ! {
}
max_cols := data_start_index + args.nr_columns
mut new_all_rows := [][]string{}
for i, row in all_rows {
for _, row in all_rows {
if row.len > max_cols {
new_all_rows << row[0..max_cols]
} else {

View File

@@ -228,7 +228,7 @@ pub fn (mut client MeilisearchClient) similar_documents(uid string, args Similar
method: .post
data: json.encode(args)
}
res := client.enable_eperimental_feature(vector_store: true)! // Enable the feature first.
client.enable_eperimental_feature(vector_store: true)! // Enable the feature first.
mut http := client.httpclient()!
rsponse := http.post_json_str(req)!
println('rsponse: ${rsponse}')

View File

@@ -19,7 +19,7 @@ pub mut:
user string = 'root'
port int = 5432
host string = 'localhost'
password string = ''
password string
dbname string = 'postgres'
}
@@ -52,8 +52,7 @@ pub fn heroscript_dumps(obj PostgresqlClient) !string {
}
pub fn heroscript_loads(heroscript string) !PostgresqlClient {
mut obj := encoderhero.decode[PostgresqlClient](heroscript)!
return PostgresqlClient{
db_: pg.DB{}
}
mut client := encoderhero.decode[PostgresqlClient](heroscript)!
client.db_ = pg.DB{}
return client
}

View File

@@ -114,5 +114,5 @@ fn (q QueryBuilder) build_query(args BuildQueryArgs) string {
fn type_to_map[T](t T) !map[string]json2.Any {
encoded_input := json2.encode(t)
return json2.raw_decode(encoded_input)!.as_map()
return json2.decode[json2.Any](encoded_input)!.as_map()
}

View File

@@ -114,7 +114,7 @@ fn cmd_docusaurus_execute(cmd Command) ! {
// ---------- FLAGS ----------
mut open_ := cmd.flags.get_bool('open') or { false }
mut buildpublish := cmd.flags.get_bool('buildpublish') or { false }
mut builddevpublish := cmd.flags.get_bool('builddevpublish') or { false }
_ := cmd.flags.get_bool('builddevpublish') or { false }
mut dev := cmd.flags.get_bool('dev') or { false }
mut reset := cmd.flags.get_bool('reset') or { false }
mut update := cmd.flags.get_bool('update') or { false }

View File

@@ -217,7 +217,7 @@ fn cmd_git_execute(cmd Command) ! {
mut gs := gittools.new(coderoot: coderoot)!
// create the filter for doing group actions, or action on 1 repo
mut filter := ''
_ := ''
mut url := ''
mut path := ''

View File

@@ -164,7 +164,7 @@ pub fn plbook_run(cmd Command) !(&playbook.PlayBook, string) {
playbook.new(path: path)!
}
dagu := cmd.flags.get_bool('dagu') or { false }
_ := cmd.flags.get_bool('dagu') or { false }
playcmds.run(plbook: plbook)!

View File

@@ -11,7 +11,7 @@ pub fn play_ssh(mut plbook PlayBook) ! {
}
// Get or create a single SSH agent instance
mut agent := sshagent.new_single(sshagent.SSHAgentNewArgs{})!
_ := sshagent.new_single(sshagent.SSHAgentNewArgs{})!
// TO IMPLEMENT:

View File

@@ -23,7 +23,7 @@ pub fn escape_regex_chars(s string) string {
// This function does not add implicit ^ and $ anchors, allowing for substring matches.
fn wildcard_to_regex(wildcard_pattern string) string {
mut regex_pattern := ''
for i, r in wildcard_pattern.runes() {
for _, r in wildcard_pattern.runes() {
match r {
`*` {
regex_pattern += '.*'

View File

@@ -38,7 +38,7 @@ pub fn set_titles(page string, maxnr int) string {
for line in lines {
mut hash_count := 0
mut first_char_idx := 0
for char_idx, r in line.runes() {
for _, r in line.runes() {
if r == ` ` {
first_char_idx++
continue
@@ -89,7 +89,7 @@ pub fn set_titles(page string, maxnr int) string {
// Remove existing numbering (e.g., "1. ", "1.1. ")
mut skip_chars := 0
mut in_numbering := true
for r_idx, r in original_title_text.runes() {
for _, r in original_title_text.runes() {
if in_numbering {
if (r >= `0` && r <= `9`) || r == `.` || r == ` ` {
skip_chars++

View File

@@ -17,7 +17,7 @@ pub mut:
apikey string
apisecret string @[secret]
configpath string
nr int = 0 // each specific instance onto this server needs to have a unique nr
nr int // each specific instance onto this server needs to have a unique nr
}
fn obj_init(obj_ LivekitServer) !LivekitServer {

View File

@@ -11,7 +11,7 @@ import incubaid.herolib.installers.virt.qemu
import os
fn startupcmd() ![]startupmanager.ZProcessNewArgs {
mut installer := get()!
_ := get()!
mut res := []startupmanager.ZProcessNewArgs{}
// THIS IS EXAMPLE CODEAND NEEDS TO BE CHANGED
// res << startupmanager.ZProcessNewArgs{
@@ -26,7 +26,7 @@ fn startupcmd() ![]startupmanager.ZProcessNewArgs {
}
fn running() !bool {
mut installer := get()!
_ := get()!
// THIS IS EXAMPLE CODEAND NEEDS TO BE CHANGED
// this checks health of lima
// curl http://localhost:3333/api/v1/s --oauth2-bearer 1234 works
@@ -147,7 +147,7 @@ fn destroy() ! {
lima
limactl
${os.home_dir()}/bin/*.lima
${os.home_dir()}/bin/*.lima
${os.home_dir()}/bin/*.lima
${os.home_dir()}/share/doc/lima
${os.home_dir()}/share/lima
${os.home_dir()}/share/man/lima*

View File

@@ -9,7 +9,7 @@ import incubaid.herolib.installers.ulist
import os
fn startupcmd() ![]startupmanager.ZProcessNewArgs {
mut installer := get()!
_ := get()!
mut res := []startupmanager.ZProcessNewArgs{}
res << startupmanager.ZProcessNewArgs{
name: 'traefik'

View File

@@ -50,7 +50,7 @@ pub fn (mut self SystemdProcess) start() ! {
systemctl start ${self.name}
'
job := osal.exec(cmd: cmd, stdout: false)!
osal.exec(cmd: cmd, stdout: false)!
// Wait for service to start with timeout
mut attempts := 0

View File

@@ -251,7 +251,7 @@ pub fn new_response_generic[D](id int, result D) ResponseGeneric[D] {
// Returns:
// - A ResponseGeneric object with result of type D, or an error if parsing fails
pub fn decode_response_generic[D](data string) !ResponseGeneric[D] {
raw := json2.raw_decode(data)!
raw := json2.decode[json2.Any](data)!
raw_map := raw.as_map()
// Validate that the response contains either result or error, but not both or neither

View File

@@ -28,7 +28,7 @@ pub fn (sim Simulation) generate_market_cap_chart() !echarts.EChartsOption {
curr: sim.params.simulation.currency
)!
for name, scenario in sim.scenarios {
for name, _ in sim.scenarios {
mut mc_row := mc_sheet.row_new(
name: 'scenario_${name}_mc'
tags: 'scenario:${name} type:market_cap'

View File

@@ -41,7 +41,7 @@ pub fn (mut sim Simulation) create_vesting_schedules() ! {
}
// Create total unlocked row
mut total_row := vesting_sheet.group2row(
_ := vesting_sheet.group2row(
name: 'total_unlocked'
include: ['type:vesting']
tags: 'summary type:total_vesting'

View File

@@ -15,7 +15,7 @@ pub fn dsite_define(sitename string) ! {
console.print_header('Add Docusaurus Site: ${sitename}')
mut c := config()!
path_publish := '${c.path_publish.path}/${sitename}'
_ := '${c.path_publish.path}/${sitename}'
path_build_ := '${c.path_build.path}'
// Get the site object after processing, this is the website which is a generic definition of a site

View File

@@ -37,8 +37,7 @@ pub fn get(args FactoryArgs) !&Site {
pub fn exists(args FactoryArgs) bool {
name := texttools.name_fix(args.name)
mut sc := sites_global[name] or { return false }
return true
return name in sites_global
}
pub fn default() !&Site {