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

Issues with flags marked as mutually exclusive during testing #2163

Open
consolethinks opened this issue Jun 19, 2024 · 1 comment
Open

Issues with flags marked as mutually exclusive during testing #2163

consolethinks opened this issue Jun 19, 2024 · 1 comment

Comments

@consolethinks
Copy link

If I set up two flags as mutually exclusive, and I set one or the other in separate test runs, then Cobra will still think that I have set them at the same time. Their values will be set correctly, but the error message about mutual exclusivity remains.

Is there any way to get around this or to fix this?

@marckhouzam
Copy link
Collaborator

marckhouzam commented Jun 21, 2024

If all this happens in the same function you will need to reset the flags as unset. Here is an example:

cobra/completions_test.go

Lines 276 to 277 in e94f6d0

// Reset the flag for the next command
nonPersistentFlag.Changed = false

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