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

AppSettings::SubcommandRequiredElseHelp affects "leaf" subcommands that don't have own subcommands #3270

Closed
2 tasks done
heroin-moose opened this issue Jan 8, 2022 · 1 comment
Labels
A-builder Area: Builder API C-bug Category: Updating dependencies S-duplicate Status: Closed as Duplicate

Comments

@heroin-moose
Copy link

Please complete the following tasks

  • I have searched the discussions
  • I have searched the existing issues

Rust Version

rustc 1.57.0 (f1edd0429 2021-11-29)

Clap Version

3.0.5

Minimal reproducible code

use clap::App;
use clap::AppSettings;

fn main() {
    let args = App::new("test")
        .global_setting(AppSettings::InferSubcommands)
        .global_setting(AppSettings::SubcommandRequiredElseHelp)
        .subcommands(vec![
            App::new("parent")
                .subcommands(vec![
                    App::new("child")
                ])
        ]);

    args.get_matches();
}

Steps to reproduce the bug with the above code

cargo run -- parent child

Actual Behaviour

A help message is displayed and program exists with status 2.

Expected Behaviour

This code should not trigger an error because commands that don't have subcommands should not be affected by this flag.

Additional Context

No response

Debug Output

No response

@heroin-moose heroin-moose added the C-bug Category: Updating dependencies label Jan 8, 2022
@epage epage added A-builder Area: Builder API S-triage Status: New; needs maintainer attention. labels Jan 10, 2022
@epage
Copy link
Member

epage commented Jan 10, 2022

Looks like this is a duplicate of #2513 (which uses yaml, making searching for it harder) . Let's continue the conversation over there.

@epage epage closed this as completed Jan 10, 2022
@epage epage added S-duplicate Status: Closed as Duplicate and removed S-triage Status: New; needs maintainer attention. labels Jan 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-builder Area: Builder API C-bug Category: Updating dependencies S-duplicate Status: Closed as Duplicate
Projects
None yet
Development

No branches or pull requests

2 participants