17 releases

0.4.0-pre.2 Oct 31, 2024
0.4.0-pre.1 Apr 29, 2024
0.3.2 Dec 18, 2023
0.3.1 Oct 22, 2022
0.2.1 Mar 6, 2021

#1760 in Procedural macros

Download history 16219/week @ 2025-09-13 18243/week @ 2025-09-20 18252/week @ 2025-09-27 14725/week @ 2025-10-04 16285/week @ 2025-10-11 15687/week @ 2025-10-18 17441/week @ 2025-10-25 17643/week @ 2025-11-01 15965/week @ 2025-11-08 14530/week @ 2025-11-15 17176/week @ 2025-11-22 15087/week @ 2025-11-29 14658/week @ 2025-12-06 15288/week @ 2025-12-13 10269/week @ 2025-12-20 8924/week @ 2025-12-27

51,181 downloads per month
Used in 29 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