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

Add ability to require arguments by group #51

Closed
ghost opened this issue Sep 14, 2014 · 2 comments
Closed

Add ability to require arguments by group #51

ghost opened this issue Sep 14, 2014 · 2 comments

Comments

@ghost
Copy link

ghost commented Sep 14, 2014

A feature that I'd love to see in PowerArgs is the ability to require arguments by group.

For example, let's say my console application declares four switch arguments: A, B, C and D. I want to require users to choose exactly two switches: one from A/B and one from C/D. The following combinations would be valid:

myapp.exe -a -c
myapp.exe -a -d
myapp.exe -b -c
myapp.exe -b -d

But the following would NOT be valid:

myapp.exe -a -b
myapp.exe -c -d

This is a feature that CommmandLineParser supports via the MutuallyExclusiveSet property, and which prevents me from switching over to PA.

@workabyte
Copy link

i believe the issue found here #47
may solve for what you are looking to do. With the example you provided you would want to do something like

public class SampleArgs
{
[ArgCantBeCombinedWith("B")]
public bool A { get; set; }
[ArgCantBeCombinedWith("A")]
public bool B { get; set; }
[ArgCantBeCombinedWith("D")]
public bool C { get; set; }
[ArgCantBeCombinedWith("C")]
public bool D { get; set; }
}

if you read through the reply provided by the creator of this project you should be able to accomplish most of what you are looking for with that feature out of the box.

Hope this helps

@adamabdelhamed
Copy link
Owner

@PCkris, thanks for writing that up. You're exactly right. @jehrenzweig, what you're asking for has been done, for example in PowerShell, but I think it's difficult for users to understand sets of required parameters (called parameter sets in PowerShell), but it's easy to understand that a particular argument can or can't be combined with another.

If you read through #47 then you'll also see that there's the if and ifnot enhancements that have been added to [ArgRequired] that give you all the flexibility you should need.

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

No branches or pull requests

2 participants