lukasmalkmus/interactive
Simple and easy interactive commandline applications. - by Lukas Malkmus
Table of Contents
Introduction
This package is build on top of the excellent golang.org/x/crypto/ssh/terminal
package and tries to simplify the creation of small and simple applications
which run in shell mode.
It isn't very powerful (yet) but has enough features for basic usage. For
example it shuts down gracefully on Ctrl^C and Ctrl^D.
Todo
- Tests!
Usage
Installation
Please use a dependency manager like glide to make sure you use a tagged release.
Install using go get
:
go get -u github.com/lukasmalkmus/interactive
Minimum setup
A more complete example can be found here.
This small application echos the entered text:
s := interactive.New(">")
s.Action = func(c *interactive.Context) error {
text, _ := c.Scan()
c.Println(text)
return nil
}
s.Run()
Returning an error instead of nil will print the error. Calling context.Close()
will close the session with the specified exit code.
Contributing
Feel free to submit PRs or to fill Issues. Every kind of help is appreciated.
License
© Lukas Malkmus, 2017
Distributed under MIT License (The MIT License
).
See LICENSE for more information.