Enable repl history
This commit is contained in:
parent
28d7be6efd
commit
468b446a4f
|
@ -21,6 +21,8 @@ package core
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"os"
|
||||||
|
"path/filepath"
|
||||||
|
|
||||||
"github.com/chzyer/readline"
|
"github.com/chzyer/readline"
|
||||||
)
|
)
|
||||||
|
@ -53,12 +55,19 @@ Replace the readline implementation with go-prompt.
|
||||||
|
|
||||||
func REPL(debug bool) {
|
func REPL(debug bool) {
|
||||||
rt := MakeRuntime(debug)
|
rt := MakeRuntime(debug)
|
||||||
|
|
||||||
rt.CreateNS("user", "REPL", true)
|
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 {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
rl.HistoryEnable()
|
||||||
defer rl.Close()
|
defer rl.Close()
|
||||||
|
|
||||||
fmt.Println(`Serene's bootstrap interpreter is used to
|
fmt.Println(`Serene's bootstrap interpreter is used to
|
||||||
|
|
|
@ -136,7 +136,6 @@ tco:
|
||||||
break tco //return
|
break tco //return
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Printf("<<< %s\n", list)
|
|
||||||
f := exprs.(*List).First()
|
f := exprs.(*List).First()
|
||||||
|
|
||||||
switch f.GetType() {
|
switch f.GetType() {
|
||||||
|
|
Loading…
Reference in New Issue