Package rline
provides a standard API wrapping the "readline" packages
(readline, replxx), and provides a comparable implementation written in
pure Go.
A comprehensive example is available:
# get source and build
$ git clone https://github.com/xo/rline.git && cd rline
# build dependencies
$ ./deps.sh
# build and run the example with readline and replxx support
$ go build -o example -tags 'rline_readline rline_replxx' ./_example
$ ./example
Please see _example/example.go
for an overview of using the
rline
package.
Both the readline and replxx libraries require static build artifacts
in the ${SRCDIR}/{readline,replxx}
directories. These can be built with the
included deps.sh
script:
# build readline and replxx dependencies
$ cd /path/to/rline
$ ./deps.sh
The readline and replxx libraries require CGO, and will not be included in a build by default. Both or either can be included by specifying an appropriate build tag:
# build with readline support
$ go build -tags rline_readline
# build with replxx support
$ go build -tags rline_replxx
# build with both readline and replxx support
$ go build -tags 'rline_readline rline_replxx'
The readline prompt can be linked against a system's standard or packaged
readline library by using the rline_readline_dynamic
tag:
# build with dynamic readline
$ go build -tags 'rline_readline_dynamic'
Aims to provide a drop in replacement with comparable feature support to GNU's readline library in pure Go, including (but not limited to):
inputrc
support (or similar)- Comprehensive Windows support
- Tab completion
And to do so with a Go-idiomatic API that allows runtime switching between prompts.
Additionally, an aim of this project is to provide higher-level functionality not available in the standard readline library:
- Syntax highlighting
- Completion menus
rline
was built primarily to support these projects:
- usql - a universal command-line interface for SQL databases