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