Skip to content

Commit

Permalink
Add NewWithReadline to have a shell with custom readline Instance (ab…
Browse files Browse the repository at this point in the history
…iosoft#105)

* add new helper NewWithReadLine to create ishell instance with a custom readline instance

* use readline config for Shell.Writer in NewWithReadline

* refactor NewWithConfig to use NewWithReadline
  • Loading branch information
pierreN authored and abiosoft committed Dec 28, 2018
1 parent d2bd206 commit 8b8aa74
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion ishell.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,12 @@ func NewWithConfig(conf *readline.Config) *Shell {
log.Println("Shell or operating system not supported.")
log.Fatal(err)
}

return NewWithReadline(rl)
}

// NewWithReadline creates a new shell with a custom readline instance.
func NewWithReadline(rl *readline.Instance) *Shell {
shell := &Shell{
rootCmd: &Cmd{},
reader: &shellReader{
Expand All @@ -84,7 +90,7 @@ func NewWithConfig(conf *readline.Config) *Shell {
buf: &bytes.Buffer{},
completer: readline.NewPrefixCompleter(),
},
writer: conf.Stdout,
writer: rl.Config.Stdout,
autoHelp: true,
}
shell.Actions = &shellActionsImpl{Shell: shell}
Expand Down

0 comments on commit 8b8aa74

Please sign in to comment.