refactor: rewrite hilbish.prompt for moonlight

midnight-edition
sammyette 2024-07-20 12:12:06 -04:00
parent f37f5b7ddc
commit 4d07f166b6
Signed by: sammyette
GPG Key ID: 904FC49417B44DCD
1 changed files with 7 additions and 3 deletions

10
api.go
View File

@ -52,7 +52,9 @@ func hilbishLoader(mlr *moonlight.Runtime) moonlight.Value {
"hinter": {hlhinter, 1, false}, "hinter": {hlhinter, 1, false},
"multiprompt": {hlmultiprompt, 1, false}, "multiprompt": {hlmultiprompt, 1, false},
"prependPath": {hlprependPath, 1, false}, "prependPath": {hlprependPath, 1, false},
*/
"prompt": {hlprompt, 1, true}, "prompt": {hlprompt, 1, true},
/*
"inputMode": {hlinputMode, 1, false}, "inputMode": {hlinputMode, 1, false},
"interval": {hlinterval, 2, false}, "interval": {hlinterval, 2, false},
"read": {hlread, 1, false}, "read": {hlread, 1, false},
@ -347,17 +349,18 @@ hilbish.prompt '%u@%h :%d $'
-- prompt: user@hostname: ~/directory $ -- prompt: user@hostname: ~/directory $
#example #example
*/ */
func hlprompt(t *rt.Thread, c *rt.GoCont) (rt.Cont, error) { func hlprompt(mlr *moonlight.Runtime, c *moonlight.GoCont) (moonlight.Cont, error) {
err := c.Check1Arg() err := mlr.Check1Arg(c)
if err != nil { if err != nil {
return nil, err return nil, err
} }
p, err := c.StringArg(0) p, err := mlr.StringArg(c, 0)
if err != nil { if err != nil {
return nil, err return nil, err
} }
typ := "left" typ := "left"
// optional 2nd arg // optional 2nd arg
/*
if len(c.Etc()) != 0 { if len(c.Etc()) != 0 {
ltyp := c.Etc()[0] ltyp := c.Etc()[0]
var ok bool var ok bool
@ -366,6 +369,7 @@ func hlprompt(t *rt.Thread, c *rt.GoCont) (rt.Cont, error) {
return nil, errors.New("bad argument to run (expected string, got " + ltyp.TypeName() + ")") return nil, errors.New("bad argument to run (expected string, got " + ltyp.TypeName() + ")")
} }
} }
*/
switch typ { switch typ {
case "left": case "left":