You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
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.
@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.
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.
The text was updated successfully, but these errors were encountered: