[][src]Crate cmdr

#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. These Scope objects can then be run by the Cmdr::cmd_loop executing commands.

Implementing the scope trait can be done by hand by implementing the command method and optionally overriding other methods to provide additional functionality. Or you can implement leave the Scope trait up to us and just use the cmdr macro to do the heavy lifting.

Any scope implements one or more command methods. Command methods names look like this: do_<command> where the do_ prefix makes sure the cmdr macro recognizes the function as a command and will be how a user will invoke a command. Command methods take a mutable reference to self (the scope) so they can change the scope when needed, a vector of &str containing any parameters passed on the command line. And they return a CommandResult. This allows the command to specify any follow-up actions to be performed (like quitting the program for example).

Re-exports

pub use cmdr_macro::cmdr;

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 by a client but will most likely be implemented for you by the cmdr macro.

Functions

cmd_loop

Execute a command loop for a scope. This is the main entry point to the cmdr library This function will take commands from the user and try to execute them against the supplied scope until one of the commands returns CommandResult::Quit