15 releases

0.3.2 Dec 18, 2023
0.3.1 Oct 22, 2022
0.2.4 Mar 2, 2022
0.2.3 Jul 21, 2021
0.1.4 Mar 5, 2021

#1950 in Procedural macros

Download history 9787/week @ 2023-12-21 7662/week @ 2023-12-28 12044/week @ 2024-01-04 9515/week @ 2024-01-11 9213/week @ 2024-01-18 8258/week @ 2024-01-25 8758/week @ 2024-02-01 10279/week @ 2024-02-08 10994/week @ 2024-02-15 9112/week @ 2024-02-22 8944/week @ 2024-02-29 9395/week @ 2024-03-07 9516/week @ 2024-03-14 10083/week @ 2024-03-21 9545/week @ 2024-03-28 7585/week @ 2024-04-04

37,982 downloads per month
Used in 19 crates (via xflags)

MIT/Apache

37KB
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);
}

No runtime deps