ClapCmd
A library to quickly build full-featured REPLs supported by CLAP and readline (provided via rustyline)
Features
- Full readline support that exposes all customization for rustyline
- emacs-style keyboard shortcuts
- command history
- Full integration with clap builders allowing for full-featured commands
- Tab completion for:
- commands and (TODO) command aliases
- arguments
- subcommands
- values supplied via
value_parsers(i.e. a list of valid values) - value hints (e.g.
ValueHint::FilePath) - TODO: callback and/or demo for how to query
value_parsersat runtime
- Callback style approach with provided state
- Customizable prompts that can be updated at anytime during execution
- Support for writing to stdout outside of the command loop without mangling the input line via
get_async_writer() - TODO: command groups
Basic Example
A minimal example showing a basic REPL is as follows:
use ;
With State
To pass state or persistent information to callbacks, provide a State class like so.
The State class must implement Clone and Default traits, and can be accessed via
the get_state() and set_state() methods on the ClapCmd reference passed into the
callback.
use ;
Related Projects
- reedline-repl-rs https://github.com/arturh85/reedline-repl-rs