Skip to content

Commit 2380f00

Browse files
authored
Make it easier to embbed/use repl.Interactive default options (#298)
1 parent 09e46d2 commit 2380f00

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

Diff for: repl/repl.go

+6-2
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,9 @@ func Interactive(options Options) int { //nolint:funlen // we do have quite a fe
220220
options.NilAndErr = true
221221
s := eval.NewState()
222222
s.NoReg = options.NoReg
223-
s.MaxDepth = options.MaxDepth
223+
if options.MaxDepth > 0 {
224+
s.MaxDepth = options.MaxDepth
225+
}
224226
s.MaxValueLen = options.MaxValueLen // 0 is unlimited so ok to copy as is.
225227
term, err := terminal.Open(context.Background())
226228
if err != nil {
@@ -248,7 +250,9 @@ func Interactive(options Options) int { //nolint:funlen // we do have quite a fe
248250
term.SetAutoHistory(false)
249251
options.DualFormat = true // because terminal doesn't (yet) do well will multi-line commands.
250252
term.NewHistory(options.MaxHistory)
251-
_ = term.SetHistoryFile(options.HistoryFile)
253+
if options.HistoryFile != "" {
254+
_ = term.SetHistoryFile(options.HistoryFile)
255+
}
252256
_ = AutoLoad(s, options) // errors already logged
253257
if options.PreInput != nil {
254258
options.PreInput(s)

0 commit comments

Comments
 (0)