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

Question: by option().multiple().groupChoice() ? #505

Open
alegomes opened this issue Apr 2, 2024 · 5 comments
Open

Question: by option().multiple().groupChoice() ? #505

alegomes opened this issue Apr 2, 2024 · 5 comments

Comments

@alegomes
Copy link

alegomes commented Apr 2, 2024

Can I use multiple() and choiceGroup() in the same option?

If not, what's the best alternative?

thanks

@ajalt
Copy link
Owner

ajalt commented Apr 2, 2024

No, I'm not sure how that would work. Options aren't ordered, so if you called the group option more than once, how would we know which instance of the group each option on the command line belongs to?

It sounds like subcommands would work better than groups here; you can repeat subccommands.

@alegomes
Copy link
Author

alegomes commented Apr 2, 2024

This is what I tought:

myCmd --groupedOpt=valueA --valueAargs1=x --valueAargs2=y --groupedOpt=valueB --valueBargs1=z

Which is the same groupChoice multiple times but with different values.

Does it make sense?

@ajalt
Copy link
Owner

ajalt commented Apr 2, 2024

The problem is that options aren't ordered, so trying to parse repeated groups would be ambiguous:

myCmd --valueAargs1=x --valueAargs2=y --groupedOpt=valueA --valueAargs2=z --groupedOpt=valueA --valueAargs2=a

@alegomes
Copy link
Author

alegomes commented Apr 2, 2024

The problem is that options aren't ordered, so trying to parse repeated groups would be ambiguous:

myCmd --valueAargs1=x --valueAargs2=y --groupedOpt=valueA --valueAargs2=z --groupedOpt=valueA --valueAargs2=a

Even if you define all sub-options values as unique? i.e. valueAargs1 ≠ valueAargs2 ≠ valueBargs1 (…) ?

@ajalt
Copy link
Owner

ajalt commented Apr 2, 2024

Yes. multiple would mean that a group can be specified more than once, so there's no way to know which instance of a given group any invocation of one of its options should belong to.

But if you have two groups and want them both used at once, why bother with groupChoice? You can just make them separate top level groups.

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