When writing a cargo subcommand, e.g., cargo foo, the first argument that the subcommand gets passed is its name, as a string (foo) in this case. So if I want to write a sub-command foo that takes one string as argument and call it like cargo foo bar, right now I need to write
#[derive(StructOpt, Debug)]
#[structopt(name = "cargo foo", about = "fooing every day")]
struct Options {
_void: String,
/// First arg
#[structopt(help = "First arg")]
first: String,
}
and this gets shown as:
USAGE:
cargo foo <_void> <first>
For more information try --help
It would be cool if structopt could be used to write cargo subcommands easily.
Basically, you what a mandatory subcommand, thus
#[derive(StructOpt, Debug)]
#[structopt(bin_name = "cargo")]
enum Opt {
#[structopt(name = "foo")]
Foo {
/// First arg
first: String,
// ...
}
}
Does it correspond to your use case?
@TeXitoi yes, this is what I wanted, thanks! I had an ergonomic problem while moving to this pattern, I've filled #59 for that.