#cli #text #command-line #cmdr


Cmdr is a library for building line-oriented text-based user interfaces

2 releases

✓ Uses Rust 2018 edition

0.1.1 Jan 3, 2019
0.1.0 Jan 3, 2019

#43 in #command-line

Download history 6/week @ 2019-01-03

1 downloads per month





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).


~19K SLoC