dpc
December 11, 2018, 5:58am
1
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
dpc
December 11, 2018, 7:30am
3
Thank you. I'll try it out.
dpc
December 12, 2018, 6:43am
4
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