[−][src]Crate cmdr
Cmdr is a library for building line-oriented text-based user interfaces.
This can be done by implementing one or more objects that implement the Cmdr::Scope trait. A command loop can then be started on a scope by calling the cmd_loop function. The command loop uses a line reader to get user input and executes them by running the appropriate functions on the supplied scope object.
Implementing a scope is as easy as creating an object with a few methods that take a vector of &str as their input and return a CommandResult. By annotating the impl block of that object the cmdr macro all functions starting annotated with #[cmd] in that block can be used as commands.
For additional functionality like setting custom prompts or setting hooks to catch unknown or empty commands additional methods can be added to the impl block. These correspond to overridable functions in the Scope trait.
Re-exports
pub use cmdr_macro::cmd; |
pub use cmdr_macro::cmdr; |
Structs
| CommandLine | A parsed command, optionally with arguments |
| ScopeCmdDescription | All information about a command method in one handy struct |
| ScopeDescription | Metadata describing a scope, is used to return help text and the list of commands that this scope exposes. |
Enums
| CommandResult | A command result. returned by one of the client-implemented command methods |
| Line | A parsed line from the user |
Traits
| Scope | Trait for implementing a Scope object. This trait can be implemented directly but will most likely be implemented for you by the cmdr macro. |
Functions
| cmd_loop | This is the main entry-point to the cmdr library. Creates a LineReader and executes its command on the scope that is passed to it. |