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

Potential regression on global args #1061

Closed
Freyskeyd opened this issue Oct 7, 2017 · 4 comments
Closed

Potential regression on global args #1061

Freyskeyd opened this issue Oct 7, 2017 · 4 comments
Labels
A-parsing Area: Parser's logic and needs it changed somehow. C-bug Category: Updating dependencies
Milestone

Comments

@Freyskeyd
Copy link

Rust Version

rustc 1.22.0-nightly (417c73891 2017-10-05)

Affected Version of clap

clap 2.26.2

Expected Behavior Summary

Using a YAML definition with an arg named quiet, defined as global I'm expecting to be able to use it in any subcommands.

Actual Behavior Summary

The quiet flag are only usable on default command, but disapear in subcommands.

Steps to Reproduce the issue

Here's the yaml

name: Test cli
version: "1.0"
args:
    - quiet:
        short: q
        help: Display only needed output
        global: true
subcommands:
    - auth:
        about: Authenticate command

main.rs

fn main() {
    let yaml = load_yaml!("cli.yml");
    let app = App::from_yaml(yaml);

    let matches = app.get_matches();

    println!("quiet: {:?}", matches.is_present("quiet"));
    println!("quiet_o: {:?}", matches.occurrences_of("quiet"));
}

Debug output

$ ./target/debug/cli
quiet: false
quiet_o: 0

$ ./target/debug/cli -q
quiet: true
quiet_o: 1

$ ./target/debug/cli -q auth
quiet: true
quiet_o: 1

$ ./target/debug/cli auth -q
quiet: false
quiet_o: 0
@kbknapp
Copy link
Member

kbknapp commented Oct 7, 2017

Thanks for filing this! I'll add it to the list as it might be related to #978 and the associated PR #1060

@kbknapp kbknapp added C: args A-parsing Area: Parser's logic and needs it changed somehow. C-bug Category: Updating dependencies labels Oct 7, 2017
@kbknapp kbknapp added this to the 2.27.0 milestone Oct 12, 2017
@kbknapp
Copy link
Member

kbknapp commented Oct 18, 2017

@Freyskeyd could you test this with the current master branch and see if it's fixed? #1070 just merged which may have helped. If not I can look into it.

@Freyskeyd
Copy link
Author

@kbknapp I will try it as soon as I can :)

@Freyskeyd
Copy link
Author

Freyskeyd commented Oct 20, 2017

@kbknapp Unfortunately, it's doesn't work with 569ced1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-parsing Area: Parser's logic and needs it changed somehow. C-bug Category: Updating dependencies
Projects
None yet
Development

No branches or pull requests

2 participants