Clap/structop: A way to not require `- -`?

I'm trying to build a command that will call git in a given directory, passing all the arguments.

However this fails:

cargo crev db git commit -a

and I have to use:

cargo crev db git -- commit -a

to make structopt/clap know that -a is not an argument to my command.

My git sub-commands looks like this:

#[derive(Debug, StructOpt, Clone)]
pub struct Git {
    /// Arguments to git command
    #[structopt(parse(from_os_str))]
    pub args: Vec<OsString>,
}

Any way to make that -- not be required?

https://github.com/TeXitoi/structopt/issues/153

I know for clap there's clap::AppSettings - Rust to do this.

From structop's raw example, it seems like this could worK:

#[derive(Debug, StructOpt, Clone)]
#[structopt(raw(setting = "structopt::clap::AppSettings::TrailingVarArg"))]
pub struct Git {
    /// Arguments to git command
    #[structopt(parse(from_os_str))]
    pub args: Vec<OsString>,
}
2 Likes

Thank you. I'll try it out.

I actually had to do it one level higher:

    /// Run raw git commands in the local proof repository
    #[structopt(name = "git")]
    #[structopt(raw(setting = "structopt::clap::AppSettings::TrailingVarArg"))]
    Git(Git),

But it works! Thank you!

1 Like