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

Can there be support for "Parameter sets" if there isn't already? #2068

Closed
red8888 opened this issue Nov 10, 2023 · 1 comment
Closed

Can there be support for "Parameter sets" if there isn't already? #2068

red8888 opened this issue Nov 10, 2023 · 1 comment

Comments

@red8888
Copy link

red8888 commented Nov 10, 2023

I'd like to be able to define various dependent flags relative to each other.

To describe behaviour like:

  • Either flagX OR flagY must be supplied
  • Mutual exclusivity like if flagX supplied flagY cannot be supplied
  • Grouping required params like if flagX is supplied then flagY must also be supplied

But I want to do this declaratively in a terse readable way.

Powershell has supported this for like a decade with "Parameter Sets" which make this trivial: https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_parameter_sets?view=powershell-7.3.

In PS this is of course built into the language itself, but could anything like this ever be supported in cobra so I don't have to roll a bunch of custom logic? For example maybe just some builtin cmd.ParameterSet() method that can be used to group PersistentFlags()/Flags() into parameter sets?

@red8888
Copy link
Author

red8888 commented Nov 10, 2023

Sorry I didn't see this, looks like this is semi supported already #1952

@red8888 red8888 closed this as completed Nov 10, 2023
This issue was closed.
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

1 participant