Closed abesto closed 5 months ago
1.75.0
4.4.12
https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=8fa6a4126712c787b6170a7663e929e7
use clap::{Parser, Subcommand, Args}; #[derive(Args, Debug)] #[group(multiple = false)] struct Group { #[clap(short, global = true)] a: bool, #[clap(short, global = true)] b: bool, } #[derive(Subcommand, Debug)] enum Sub { Foo } #[derive(Parser, Debug)] struct Cli { #[clap(flatten)] g: Group, #[command(subcommand)] sub: Sub, } pub fn main() -> anyhow::Result<()> { dbg!(Cli::try_parse_from(["cli", "-a", "foo", "-b"])?); dbg!(Cli::try_parse_from(["cli", "-a", "-b", "foo"])?); Ok(()) }
cargo run / run the Playground snippet
cargo run
The first line of main (cli -a foo -b) doesn't explode, but the second line does.
main
cli -a foo -b
The first line should explode as well.
I think this is another manifestation of https://github.com/clap-rs/clap/issues/1546#issuecomment-1198809765
No response
Since this is a larger issue than the original title, I've renamed #1546 so we can track all of this in one place and closing in favor of that.
Yep, that makes sense. Thanks!
Please complete the following tasks
Rust Version
1.75.0
Clap Version
4.4.12
Minimal reproducible code
https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=8fa6a4126712c787b6170a7663e929e7
Steps to reproduce the bug with the above code
cargo run
/ run the Playground snippetActual Behaviour
The first line of
main
(cli -a foo -b
) doesn't explode, but the second line does.Expected Behaviour
The first line should explode as well.
Additional Context
I think this is another manifestation of https://github.com/clap-rs/clap/issues/1546#issuecomment-1198809765
Debug Output
No response