Enable repl history

This commit is contained in:
Sameer Rahmani 2020-11-20 12:33:15 +00:00
parent 28d7be6efd
commit 468b446a4f
2 changed files with 11 additions and 3 deletions

View File

@ -21,6 +21,8 @@ package core
import (
"fmt"
"os"
"path/filepath"
"github.com/chzyer/readline"
)
@ -53,12 +55,19 @@ Replace the readline implementation with go-prompt.
func REPL(debug bool) {
rt := MakeRuntime(debug)
rt.CreateNS("user", "REPL", true)
rl, err := readline.New("> ")
rl, err := readline.NewEx(&readline.Config{
Prompt: "> ",
HistoryFile: filepath.Join(os.Getenv("HOME"), ".serene.history"),
InterruptPrompt: "^C",
EOFPrompt: "exit",
HistorySearchFold: true,
})
if err != nil {
panic(err)
}
rl.HistoryEnable()
defer rl.Close()
fmt.Println(`Serene's bootstrap interpreter is used to

View File

@ -136,7 +136,6 @@ tco:
break tco //return
}
fmt.Printf("<<< %s\n", list)
f := exprs.(*List).First()
switch f.GetType() {