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::{Subcommand,Parser};// v4.5.16#[derive(Subcommand)]enumSub{Test{field_name:u64}}#[derive(Parser)]structCli{#[command(subcommand)]cmd:Sub,#[arg(long, global = true)]field_name:Option<String>}fnmain(){let args = Cli::parse_from(["cmd","test","42"]);drop(args);}
When parsing the subcommand, we need a way to refer to both the parent argument and the subcommand's argument. Due to limitations in derives, to either make this automatic or error, we'd have to handle this at runtime through the design of the derive traits which would require a lot of complex logic to be generated and we'd need to constantly be making breaking changes on the traits or have no stability guarantees on them. This is being tracked in #3133.
#4701 would reduce the chance of hitting this problem.
Closing in favor of those two issues. If there is a reason we should keep this open separately, let us know!
Please complete the following tasks
Rust Version
rustc 1.78.0 (9b00956e5 2024-04-29)
Clap Version
4.5.16
Minimal reproducible code
Playground Link
Steps to reproduce the bug with the above code
Actual Behaviour
When I run this I get the following error:
Expected Behaviour
It should either return a compile error due to the duplicate field name or parse correctly.
Additional Context
No response
Debug Output
The text was updated successfully, but these errors were encountered: