This commit is contained in:
2025-08-16 11:23:58 +02:00
parent be19609855
commit de60c5f78e
38 changed files with 1374 additions and 869 deletions

View File

@@ -11,17 +11,17 @@ fn donedb() !&redisclient.Redis {
pub fn done_set(key string, val string) ! {
mut db := donedb()!
db.hset("context:done",key, val)!
db.hset('context:done', key, val)!
}
pub fn done_get(key string) ?string {
mut db := donedb() or { panic(err) }
return db.hget("context:done", key) or { return none }
return db.hget('context:done', key) or { return none }
}
pub fn done_delete(key string) ! {
mut db := donedb()!
db.hdel("context:done", key)!
db.hdel('context:done', key)!
}
pub fn done_get_str(key string) string {
@@ -36,7 +36,7 @@ pub fn done_get_int(key string) int {
pub fn done_exists(key string) bool {
mut db := donedb() or { panic(err) }
return db.hexists("context:done", key) or { false }
return db.hexists('context:done', key) or { false }
}
pub fn done_print() ! {
@@ -52,5 +52,5 @@ pub fn done_print() ! {
pub fn done_reset() ! {
mut db := donedb()!
db.del("context:done")!
db.del('context:done')!
}

View File

@@ -482,7 +482,6 @@ pub fn exec_string(cmd Command) !string {
return job.cmd.scriptpath
}
@[params]
pub struct CommandFast {
pub mut:
@@ -491,18 +490,17 @@ pub mut:
work_folder string // location where cmd will be executed
environment map[string]string // env variables
ignore_error_codes []int
debug bool // if debug will put +ex in the script which is being executed and will make sure script stays
debug bool // if debug will put +ex in the script which is being executed and will make sure script stays
includeprofile bool
notempty bool
}
//execute something fast, make sure it returns an error if the result is empty
//source the
// execute something fast, make sure it returns an error if the result is empty
// source the
pub fn exec_fast(cmd_ CommandFast) !string {
mut cmd_str := texttools.dedent(cmd_.cmd)
mut toexecute:=[]string{}
mut toexecute := []string{}
if cmd_.debug {
// Add +ex for debug mode if it's a bash script
@@ -515,13 +513,12 @@ pub fn exec_fast(cmd_ CommandFast) !string {
toexecute << profile_path_source_and()!
}
for key,val in cmd_.environment {
toexecute << 'export ${key}=${val}'
for key, val in cmd_.environment {
toexecute << 'export ${key}=${val}'
}
if cmd_.work_folder.len > 0 {
toexecute << "cd ${cmd_.work_folder}"
toexecute << 'cd ${cmd_.work_folder}'
}
toexecute << cmd_str
@@ -533,7 +530,7 @@ pub fn exec_fast(cmd_ CommandFast) !string {
if result.exit_code != 0 {
if !(cmd_.ignore_error || result.exit_code in cmd_.ignore_error_codes) {
return error("couldn't execute '${cmd_.cmd}', result code: ${result.exit_code}\n${result.output}")
}
}
}
if cmd_.notempty && result.output.len == 0 {
@@ -541,4 +538,4 @@ pub fn exec_fast(cmd_ CommandFast) !string {
}
return result.output
}
}