minicmd 0.1.0

Extremely simple and minimal command-line argument parser
Documentation
  • Coverage
  • 7.69%
    1 out of 13 items documented0 out of 10 items with examples
  • Size
  • Source code size: 6.9 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 1.61 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 17s Average build duration of successful builds.
  • all releases: 17s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Homepage
  • malkicodes/minicmd
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • malkicodes

minicmd

An extremely simple and minimal command-line argument parser, with similar syntax to Go's flag package.

use minicmd::MiniCmd;

fn main() {
    let config: MiniCmd = MiniCmd::parse();

    let greeting: &str = config
        .value("greeting")
        .unwrap_or(if config.flag("formal") {
            "Salutations"
        } else {
            "Hello"
        });

    if config.args_is_empty() {
        println!("{greeting}, World!")
    } else {
        for name in config.args() {
            println!("{greeting}, {name}!",);
        }
    }
}
$ cargo run
Hello, World!
$ cargo run -- -formal
Salutations, World!
$ cargo run -- -greeting=Sup
Sup, World!
$ cargo run -- Alice Bob "John Doe"
Hello, Alice!
Hello, Bob!
Hello, John Doe!