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

flags are a flat namespace #247

Open
mleku opened this issue May 7, 2024 · 2 comments
Open

flags are a flat namespace #247

mleku opened this issue May 7, 2024 · 2 comments

Comments

@mleku
Copy link

mleku commented May 7, 2024

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 error

not 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

@alexflint
Copy link
Owner

alexflint commented May 9, 2024

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.

@mleku
Copy link
Author

mleku commented May 10, 2024

i don't mind it being flat just it should be documented and there should be a validation to ensure no collisions

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants