#cli #text #command-line #cmdr


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

19 releases

0.3.12 Nov 1, 2020
0.3.11 Oct 28, 2019
0.3.9 Jun 16, 2019
0.3.6 May 23, 2019
0.1.3 Jan 26, 2019

#104 in Command-line interface

Download history 38/week @ 2021-02-24 33/week @ 2021-03-03 4/week @ 2021-03-10 4/week @ 2021-03-17 50/week @ 2021-03-24 21/week @ 2021-03-31 27/week @ 2021-04-07 78/week @ 2021-04-14 6/week @ 2021-04-21 6/week @ 2021-04-28 4/week @ 2021-05-05 24/week @ 2021-05-12 3/week @ 2021-05-19 17/week @ 2021-05-26 6/week @ 2021-06-02 41/week @ 2021-06-09

112 downloads per month


549 lines

cmdr   Build Status

Cmdr is a library for building line-oriented text-based user interfaces. It lets you focus on writing the implementations of your commands while it handles user interaction, parsing etc.

Out of the box CMDR gives you;

  • Command line parsing
  • Command history
  • Help functions and discoverability
  • Auto completion (not yet implemented)

To use CMDR you write the commands you want your user to interact with as functions on one or more Scope types. By implementing the scope trait cmdr can implement and execute your supplied commands. Implementing the Scope trait is as easy by using the supplied cmdr macro and annotating your commands with the cmd annotation to provide useful metadata on your commands. Doc strings in your command will be picked up automatically and used as help text.

use cmdr::*;

/// Example scope that implements two commands, greet and quit
struct GreeterScope {}

impl GreeterScope {
    /// Cmdr command to greet someone. Takes one parameter and prints a greeting
    fn greet(&self, args: &[String]) -> CommandResult {
        println!("Hello {}", args[0]);

    /// Cmdr command to quit the application by returning CommandResult::Quit
    fn quit(&self, _args: &[String]) -> CommandResult {

/// Main function that creates the scope and starts a command loop for it
fn main() -> cmdr::Result<()> {
    cmd_loop(&mut GreeterScope {})?;

More information

version: 0.3.11


Licensed under either of

at your option.


Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.


~52K SLoC