Xflags: fast-to-compile proc macro for CLI args


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.
    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> {

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

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


The src-based part of the API looks original and interesting: having the option to manually cache the output of a proc-macro can come in handy :slightly_smiling_face:

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.