Open mleku opened 6 months ago
If you have an option -a
on both the top-level struct and also on a subcommand, then depending on where in the command line you put the -a
, you will either be interacting with the top-level or subcommand version of that option:
./my-program -a mysubcommand # goes to the top-level version of the -a option
./my-program mysubcommand -a # goes to the subcommand version of the -a option
I agree this is a bit dicey, actually. I'm worried that it's unhelpful. And you're right that it's not documented! I'll fix that.
i don't mind it being flat just it should be documented and there should be a validation to ensure no collisions
i just tested and with a subcommand and a flag value with the same
-a
the one in the subcommand did not work or register an errornot sure if this is an error or just something that should be pointed out in the documentation for the subcommands, and it might be worth adding some kind of validation for duplicate items to warn when using the
MustParse
method