Skip to content
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

'infer subcommand' doesn't work with nested subcommands #289

Closed
danieleades opened this issue Dec 1, 2019 · 1 comment · Fixed by #290
Closed

'infer subcommand' doesn't work with nested subcommands #289

danieleades opened this issue Dec 1, 2019 · 1 comment · Fixed by #290

Comments

@danieleades
Copy link

When InferSubcommands is enabled, subcommand inference only works for the top level of subcommands- to call nested subcommands the entire command must be written out.

use structopt::{StructOpt, clap::AppSettings};

#[derive(StructOpt)]
#[structopt(setting = AppSettings::InferSubcommands)]
enum Args {
    SomeCommand(SubSubCommand),
    AnotherCommand,
}

#[derive(StructOpt)]
#[structopt(setting = AppSettings::InferSubcommands)]
enum SubSubCommand {
    TestCommand,
}

fn main() {
    let args = Args::from_args();
}
  • cargo run some-command test-command works
  • cargo run some test-command works
  • cargo run some-command test doesn't work
  • cargo run some test doesn't work

i've tried both the above syntax, and explicitly marking with the #[structopt(subcommand] tag.

@CreepySkeleton
Copy link
Collaborator

This is the same problem as #151 , the same fix should apply

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants