You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
use clap::{Parser,Args,Subcommand};// 3.0.14#[derive(Parser,Debug)]structOptions{#[clap(subcommand)]command:Command1,}#[derive(Subcommand,Debug)]enumCommand1{A(Command1AOptions),}#[derive(Args,Debug)]structCommand1AOptions{#[clap(subcommand)]command:Command2,#[clap(long, global = true)]flag1:bool,}#[derive(Subcommand,Debug)]enumCommand2{B{#[clap(subcommand)]command:Command3,#[clap(long, global = true)]flag2:bool,},}#[derive(Subcommand,Debug)]enumCommand3{C(Command3COptions),}#[derive(Args,Debug)]structCommand3COptions{}fnmain(){let options = Options::parse();dbg!(options);}
Steps to reproduce the bug with the above code
cargo run -- a b c --flag2 --flag1
This passes both global flags at the lowest level (flag1 is declared with a, flag2 is declared with b)
Actual Behaviour
flag1 is correctly set to true, but flag2 is false!
Finished dev [unoptimized + debuginfo] target(s) in 0.04s
Running `target/debug/clap_test a b c --flag2 --flag1`
[src/main.rs:42] options = Options {
command: A(
Command1AOptions {
command: B {
command: C(
Command3COptions,
),
flag2: false,
},
flag1: true,
},
),
}
epage
added
A-parsing
Area: Parser's logic and needs it changed somehow.
E-easy
Call for participation: Experience needed to fix: Easy / not much
labels
Feb 9, 2022
The fix was fast but the part that might be slow is the release. I generally aim to release as soon as a user-facing change is in but I'm batching up some deprecations, so focusing on finish that first. Sorry for the delay.
Please complete the following tasks
Rust Version
rustc 1.58.0-nightly (65f3f8b22 2021-11-21)
Clap Version
3.0.14
Minimal reproducible code
Steps to reproduce the bug with the above code
cargo run -- a b c --flag2 --flag1
This passes both global flags at the lowest level (flag1 is declared with
a
, flag2 is declared withb
)Actual Behaviour
flag1 is correctly set to
true
, but flag2 isfalse
!Expected Behaviour
Both
flag1
andflag2
should betrue
Additional Context
No response
Debug Output
debug.txt
The text was updated successfully, but these errors were encountered: