diff --git a/README.md b/README.md index 442f2e0..02d58c2 100644 --- a/README.md +++ b/README.md @@ -2,3 +2,5 @@ Wrapper around [x/term](https://github.com/golang/term) for a "readline" like library for the [grol](https://github.com/grol-io/grol#grol) command line repl and others. + +See [example/main.go](example/main.go) for a rather complete example/demo. diff --git a/example/main.go b/example/main.go index a9dbe4b..827fb19 100644 --- a/example/main.go +++ b/example/main.go @@ -23,9 +23,10 @@ const ( afterCmd = "after " exitCmd = "exit" helpCmd = "help" + testMLCmd = "multiline" ) -var commands = []string{promptCmd, afterCmd, exitCmd, helpCmd} +var commands = []string{promptCmd, afterCmd, exitCmd, helpCmd, testMLCmd} // func(line string, pos int, key rune) (newLine string, newPos int, ok bool) @@ -43,6 +44,10 @@ func autoCompleteCallback(line string, pos int, key rune) (newLine string, newPo } for _, c := range commands { // for now all have unique prefixes if strings.HasPrefix(c, line) { + if c == testMLCmd { + ret := "multiline {\r\n\tline1\r\n\tline2" + return ret, len(ret), true + } return c, len(c), true } }