2024-04-10 10:45:58 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"github.com/chzyer/readline"
|
|
|
|
"github.com/lmika/cmdlang-proto/cmdlang"
|
|
|
|
"log"
|
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
rl, err := readline.New("> ")
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
defer rl.Close()
|
|
|
|
|
|
|
|
inst := cmdlang.New()
|
|
|
|
ctx := context.Background()
|
|
|
|
|
|
|
|
for {
|
|
|
|
line, err := rl.Readline()
|
|
|
|
if err != nil { // io.EOF
|
|
|
|
break
|
|
|
|
}
|
|
|
|
|
2024-04-10 11:58:06 +00:00
|
|
|
if err := inst.EvalAndDisplay(ctx, line); err != nil {
|
2024-04-10 10:45:58 +00:00
|
|
|
log.Printf("%T: %v", err, err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|