-
Notifications
You must be signed in to change notification settings - Fork 150
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Default subcommand #68
Comments
I don't get the feature. You can have an optional subcommand: #[macro_use] extern crate structopt;
use structopt::StructOpt;
#[derive(StructOpt, Debug)]
struct Opt {
#[structopt(subcommand)]
subcommand: Option<Cmd>
}
#[derive(StructOpt, Debug)]
enum Cmd {
#[structopt(name = "list-units")]
ListUnits,
#[structopt(name = "status")]
Status,
}
fn main() {
let opt = Opt::from_args();
println!("{:?}", opt);
} Having a "default subcommand" is quite complicated: you need something to create a default variant. I need a real case example to understand the need. |
@bb010g ping |
I'd simply like to be able to nicely have a default command, like you can have defaults for values. You could argue that |
If you type |
That would be an issue. It looks like systemctl doesn't really have any subcommand-specific flags, which probably helps them get away with this. I'd lean towards prioritizing main command options first, and then subcommands if that fails, but that would introduce a new level of complexity to parsing. So yeah, with that in mind, explicitly using an |
I don't have any great idea about that. Now, with the context, it should be a feature request to clap that parse the command line, not structopt. |
Is there an issue or resolution to this in clap? |
I can't find anything with a quick search |
The feature request on clap is clap-rs/clap#975 but it has also been closed... |
It would be nice if you could specify a default subcommand, like
systemctl
does withlist-units
. It could look like this:The text was updated successfully, but these errors were encountered: