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
Flag parsing error when flag value matches subcommand name #1913
Comments
Is this the same as #1777 ? |
@marckhouzam Definitely sounds like the same issue, yeah. Seems like it's not actually fixed. |
Duplicate #1777 Thanks for the test program @watsonian. I did see the problem with it. So I wondered if you were using an old version of cobra but you were not. This is when I realized that the fix for this hasn't been released yet 😄 , as we can see from the milestone set for #1781 . I have re-tried your test program with the main branch of cobra and it properly works in that case. |
@marckhouzam It looks like the actual fix for this was merged 4 months ago and still isn't released. Do you know when the next release will be? |
We usually do releases every four months, so one should be coming up soon. |
I seem to have run into a bug that surfaces when you pass a value into a flag that matches the name of a subcommand. For example, suppose you have a command like this:
where
configs
is a subcommand, but we're also passing that in as the value to the--project
flag. In that scenario, the value forproject
ends up being--config
and the value forconfig
ends up being empty. If you change the value being passed to--project
to anything else, it works fine. It also starts working fine if you leave the value being passed to--project
as is, but rename the subcommand.Here's video demonstrating the issue:
https://www.loom.com/share/22d1caba74644c939e978fd3277a437d
And here's the sample code demonstrating the problem: cobra-tester.zip
The text was updated successfully, but these errors were encountered: