fix: Rename reporomt to heroprompt

This commit is contained in:
Mahmoud-Emad
2025-08-13 14:17:29 +03:00
parent 3f82240564
commit 5c77c6bd8d
8 changed files with 43 additions and 43 deletions

View File

@@ -1,7 +1,7 @@
!!hero_code.generate_client
name:'reprompt'
classname:'RepromptWorkspace'
name:'heroprompt'
classname:'HeropromptWorkspace'
singleton:0
default:1
hasconfig:1

View File

@@ -1,4 +1,4 @@
# reprompt
# heroprompt
@@ -7,9 +7,9 @@ To get started
```vlang
import freeflowuniverse.herolib.clients. reprompt
import freeflowuniverse.herolib.clients. heroprompt
mut client:= reprompt.get()!
mut client:= heroprompt.get()!
client...
@@ -21,7 +21,7 @@ client...
## example heroscript
```hero
!!reprompt.configure
!!heroprompt.configure
secret: '...'
host: 'localhost'
port: 8888

View File

@@ -1,4 +1,4 @@
module reprompt
module heroprompt
import freeflowuniverse.herolib.data.paramsparser
import freeflowuniverse.herolib.data.encoderhero
@@ -6,7 +6,7 @@ import freeflowuniverse.herolib.core.pathlib
import os
// your checking & initialization code if needed
fn (mut ws RepromptWorkspace) reprompt() !string {
fn (mut ws HeropromptWorkspace) heroprompt() !string {
// TODO: fill in template based on selection
return ''
}

View File

@@ -1,12 +1,12 @@
module reprompt
module heroprompt
import freeflowuniverse.herolib.core.base
import freeflowuniverse.herolib.core.playbook { PlayBook }
import freeflowuniverse.herolib.ui.console
__global (
reprompt_global map[string]&RepromptWorkspace
reprompt_default string
heroprompt_global map[string]&HeropromptWorkspace
heroprompt_default string
)
/////////FACTORY
@@ -25,61 +25,61 @@ fn args_get(args_ ArgsGet) ArgsGet {
return args
}
pub fn get(args_ ArgsGet) !&RepromptWorkspace {
pub fn get(args_ ArgsGet) !&HeropromptWorkspace {
mut context := base.context()!
mut args := args_get(args_)
mut obj := RepromptWorkspace{
mut obj := HeropromptWorkspace{
name: args.name
}
if args.name !in reprompt_global {
if args.name !in heroprompt_global {
if !exists(args)! {
set(obj)!
} else {
heroscript := context.hero_config_get('reprompt', args.name)!
heroscript := context.hero_config_get('heroprompt', args.name)!
mut obj_ := heroscript_loads(heroscript)!
set_in_mem(obj_)!
}
}
return reprompt_global[args.name] or {
println(reprompt_global)
return heroprompt_global[args.name] or {
println(heroprompt_global)
// bug if we get here because should be in globals
panic('could not get config for reprompt with name, is bug:${args.name}')
panic('could not get config for heroprompt with name, is bug:${args.name}')
}
}
// register the config for the future
pub fn set(o RepromptWorkspace) ! {
pub fn set(o HeropromptWorkspace) ! {
set_in_mem(o)!
mut context := base.context()!
heroscript := heroscript_dumps(o)!
context.hero_config_set('reprompt', o.name, heroscript)!
context.hero_config_set('heroprompt', o.name, heroscript)!
}
// does the config exists?
pub fn exists(args_ ArgsGet) !bool {
mut context := base.context()!
mut args := args_get(args_)
return context.hero_config_exists('reprompt', args.name)
return context.hero_config_exists('heroprompt', args.name)
}
pub fn delete(args_ ArgsGet) ! {
mut args := args_get(args_)
mut context := base.context()!
context.hero_config_delete('reprompt', args.name)!
if args.name in reprompt_global {
// del reprompt_global[args.name]
context.hero_config_delete('heroprompt', args.name)!
if args.name in heroprompt_global {
// del heroprompt_global[args.name]
}
}
// only sets in mem, does not set as config
fn set_in_mem(o RepromptWorkspace) ! {
fn set_in_mem(o HeropromptWorkspace) ! {
mut o2 := obj_init(o)!
reprompt_global[o.name] = &o2
reprompt_default = o.name
heroprompt_global[o.name] = &o2
heroprompt_default = o.name
}
pub fn play(mut plbook PlayBook) ! {
mut install_actions := plbook.find(filter: 'reprompt.configure')!
mut install_actions := plbook.find(filter: 'heroprompt.configure')!
if install_actions.len > 0 {
for install_action in install_actions {
heroscript := install_action.heroscript()
@@ -89,9 +89,9 @@ pub fn play(mut plbook PlayBook) ! {
}
}
// switch instance to be used for reprompt
// switch instance to be used for heroprompt
pub fn switch(name string) {
reprompt_default = name
heroprompt_default = name
}
// helpers

View File

@@ -1,4 +1,4 @@
module reprompt
module heroprompt
import freeflowuniverse.herolib.data.paramsparser
import freeflowuniverse.herolib.data.encoderhero
@@ -12,20 +12,20 @@ const default = true
// THIS THE THE SOURCE OF THE INFORMATION OF THIS FILE, HERE WE HAVE THE CONFIG OBJECT CONFIGURED AND MODELLED
@[heap]
pub struct RepromptWorkspace {
pub struct HeropromptWorkspace {
pub mut:
name string = 'default'
dirs []RepromptDir
dirs []HeropromptDir
}
pub struct RepromptDir {
pub struct HeropromptDir {
pub mut:
path pathlib.Path
selections []string // paths selected in the RepromptDir
selections []string // paths selected in the HeropromptDir
}
// your checking & initialization code if needed
fn obj_init(mycfg_ RepromptWorkspace) !RepromptWorkspace {
fn obj_init(mycfg_ HeropromptWorkspace) !HeropromptWorkspace {
mut mycfg := mycfg_
if mycfg.password == '' && mycfg.secret == '' {
return error('password or secret needs to be filled in for ${mycfg.name}')
@@ -35,14 +35,14 @@ fn obj_init(mycfg_ RepromptWorkspace) !RepromptWorkspace {
/////////////NORMALLY NO NEED TO TOUCH
pub fn heroscript_dumps(obj RepromptWorkspace) !string {
pub fn heroscript_dumps(obj HeropromptWorkspace) !string {
// create heroscript following template
// check for our homedir on our machine and replace in the heroscript to @HOME in path
return encoderhero.encode[RepromptWorkspace](obj)!
return encoderhero.encode[HeropromptWorkspace](obj)!
}
pub fn heroscript_loads(heroscript string) !RepromptWorkspace {
// TODO: parse heroscript populate RepromptWorkspace
mut obj := encoderhero.decode[RepromptWorkspace](heroscript)!
pub fn heroscript_loads(heroscript string) !HeropromptWorkspace {
// TODO: parse heroscript populate HeropromptWorkspace
mut obj := encoderhero.decode[HeropromptWorkspace](heroscript)!
return obj
}

View File

@@ -1,7 +1,7 @@
!!reprompt.configure name:"default"
!!heroprompt.configure name:"default"
!!reprompt.workspace_dir name:"default"
!!heroprompt.workspace_dir name:"default"
path:"@HOME/code/github/freeflowuniverse/herolib/lib/builder"
selection:"path1,path2" //paths are relative in the path of workspace
filter_exclude:","