#cli #text #command-line #cmdr


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

12 releases

✓ Uses Rust 2018 edition

0.3.5 May 11, 2019
0.3.4 Mar 26, 2019
0.2.1 Mar 2, 2019
0.1.3 Jan 26, 2019

#35 in #command-line

Download history 9/week @ 2019-01-23 2/week @ 2019-01-30 4/week @ 2019-02-06 4/week @ 2019-02-13 7/week @ 2019-02-20 31/week @ 2019-02-27 18/week @ 2019-03-06 28/week @ 2019-03-13 83/week @ 2019-03-20 32/week @ 2019-03-27 20/week @ 2019-04-03 8/week @ 2019-04-10 2/week @ 2019-04-17 9/week @ 2019-04-24 23/week @ 2019-05-01

89 downloads per month


374 lines


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.


~45K SLoC