8 releases

0.2.2 Jun 10, 2021
0.2.1 Mar 6, 2021
0.1.4 Mar 5, 2021

#46 in Command-line interface

Download history 680/week @ 2021-02-26 1933/week @ 2021-03-05 2772/week @ 2021-03-12 2582/week @ 2021-03-19 2536/week @ 2021-03-26 3114/week @ 2021-04-02 3018/week @ 2021-04-09 3031/week @ 2021-04-16 2992/week @ 2021-04-23 3252/week @ 2021-04-30 3197/week @ 2021-05-07 2969/week @ 2021-05-14 2996/week @ 2021-05-21 3015/week @ 2021-05-28 3077/week @ 2021-06-04 2452/week @ 2021-06-11

12,636 downloads per month
Used in 2 crates (via ra_ap_rust-analyzer)

MIT/Apache

43KB
1K SLoC

API reference

xflags

Moderately simple command line arguments parsing:

mod flags {
    use std::path::PathBuf;

    xflags::xflags! {
        src "./examples/basic.rs"

        cmd my-command
            required path: PathBuf
        {
            optional -v, --verbose
        }
    }

    // generated start
    // The following code is generated by `xflags` macro.
    // Run `env UPDATE_XFLAGS=1 cargo build` to regenerate.
    #[derive(Debug)]
    pub struct MyCommand {
        pub path: PathBuf,

        pub verbose: bool,
    }

    impl MyCommand {
        pub const HELP: &'static str = Self::HELP_;

        pub fn from_env() -> xflags::Result<Self> {
            Self::from_env_()
        }

        pub fn from_vec(args: Vec<std::ffi::OsString>) -> xflags::Result<Self> {
            Self::from_vec_(args)
        }
    }
    // generated end
}

fn main() {
    let flags = flags::MyCommand::from_env();
    println!("{:#?}", flags);
}

Dependencies

~79KB