Integrated console application library, using Go structs as commands, with menus, completions, hints, history, Vim mode, $EDITOR usage, and more ...
Integrated console application library, using Go structs as commands, with menus, completions, hints, history, Vim mode, $EDITOR usage, and more ...
maxlandon/gonsole
Gonsole - Integrated Console Application library
This package rests on a readline console library, (giving advanced completion, hint, input and history system), and the go-flags commands library. Also added, a bit of optional boilerplate for better user experience.
The purpose of this library is to offer a complete off-the-shelf console application, with some key aspects:
Simple Usage
The library is made to work with sane but powerful defaults. Paste the following, run it, and take a look around to get a feel, without your commands. Default editing mode is Vim. THis example doesn't have an exit command: you'll need to close your terminal.
If you're still here, at least you want to declare and bind commands. Just as everything else possible with this library, it is explained in the Wiki, although with more pictures than text (I like pictures), because the code is heavily documented (I don't like to repeat myself). Using the library, as usual:
Documentation Contents
Developers
Users
Features
The list of features supported or provided by this library can fall into 2 different categories: the shell/console interface part, and the commands/parsing logic part. Some of the features below are simply extrated from my readline library (everything below Shell Details).
Menus & Commands
Shell details
$EDITOR
(vi
in the example - enabled by pressing[ESC]
followed by[v]
)Completion engine
Grid
,List
andMap
)List
completion groups, ability to have alternative candidates (used for displaying--long
and-s
(short) options, with descriptions)Others
$
or@
) is detected, anywhere in the line. These variables are expanded at command execution time, and work in completions as well.help
command can be bound to the console, in additional to default-h
/--help
flags for every command.Prompt system & Colors
Hints & Syntax highlighting
Command history
Status & Support
Support:
TO DO:
-sP
,-oL
, etc)config load
commandVersion Information
The version string will be based on Semantic Versioning. ie version numbers will be formatted
(major).(minor).(patch)
- for example2.0.1
major
releases will have breaking changes. Be sure to read CHANGES.md for upgrade instructionsminor
releases will contain new APIs or introduce new user facing features which may affect useability from an end user perspective. Howeverminor
releases will not break backwards compatibility at the source code level and nor will it break existing expected user-facing behavior. These changes will be documented in CHANGES.md toopatch
releases will be bug fixes and such like. Where the code has changed but both API endpoints and user experience will remain the same (except where expected user experience was broken due to a bug, then that would be bumped to either aminor
ormajor
depending on the significance of the bug and the significance of the change to the user experience)Any updates to documentation, comments within code or the example code will not result in a version bump because they will not affect the output of the go compiler. However if this concerns you then I recommend pinning your project to the git commit hash rather than a
patch
releaseLicense
The
gonsole
library is distributed under the Apache License (Version 2.0, January 2004) (http://www.apache.org/licenses/). All the example code and documentation in/examples
,/completers
is public domain.