#cli #argument-parser #command-line-parser #commander


A simple, lightweight, command line argument parser for rust codebases

8 unstable releases (3 breaking)

1.0.0-beta-1 May 18, 2022
0.6.1 May 24, 2022
0.5.2 Apr 21, 2022
0.4.1 Apr 17, 2022
0.1.0 Mar 9, 2022

#214 in Command-line interface

Download history 13/week @ 2023-07-26 7/week @ 2023-08-02 11/week @ 2023-08-09 23/week @ 2023-08-16 18/week @ 2023-08-23 17/week @ 2023-08-30 28/week @ 2023-09-06 10/week @ 2023-09-13 7/week @ 2023-09-20 17/week @ 2023-09-27 9/week @ 2023-10-04 10/week @ 2023-10-11 13/week @ 2023-10-18 30/week @ 2023-10-25 18/week @ 2023-11-01 15/week @ 2023-11-08

77 downloads per month
Used in 2 crates

MIT license


A simple, lightweight and extensible command line argument parser for rust codebases.

GitHub Workflow Status Crates.io Crates.io

This crate aims to provide you with an easy-to-use and extensible API without compromising the speed and performance that is expected of rust codebases. The syntax of the builder interface can be attributed to the javascript package commander-js. To get started, create a new instance of the program and manipulate it as shown.

A basic example

The following is a basic example on how to use the crate. More in depth documentation can be found from docs.rs or the github repo.

let mut program = Program::new();

    .description("An example CLI")
    .author("Author's name");

    .argument("<app-name>", "Pass the name of the app to test")
    .description("A test command")
    .option("-s --skip", "Skip checking/installing the dependencies")
    .option("-p --priority", "The priority to use when testing apps")
    .action(|matches| { dbg!(matches); });

// ...


Extending the functionality using event listeners

The default behaviour of the program can be easily extended or even overriden by use of event listeners. View the docs to see all possible events of the program.


program.on(Event::OutputVersion, |config|{
    let prog_ref = config.get_program();
    println!("Current program version is: {}", prog_ref.get_version());

    let prog_ref = config.get_program();
    println!("This program was authored by: {}", prog_ref.get_author());

    println!("An Aram Mojtabai banger!!!😂")

// ...

Configuring program settings

Modify the settings to control the behavior of the program. See the documentation for all possible configurable settings

// ...


// ...

Customizing themes and patterns

You can define your own color pallete to be used when printing to std_out. Also, you can control how the information is printed by use of patterns.

// ...

use Color::*;
    Green, Magenta, Blue, Red, White

// ...

Refer to docs.rs for full documentation on the crate. Also check out the repository on github for examples of crate usage here. If you found this crate useful, consider starring this repo.


Whether you have an awesome color palette to create a new predefined theme, or you wish to add a new use-case to the examples/ directory, or you have a change that can improve the crate, all contributions are welcome and highly appreciated!