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
After implementing the or, not, xor, nand boolean operations, and all the comparison operations >, >=... on the Count class. We get a great deal of flexibility: rules like "this option can only be used this other one is set ..." can be implemented just with this.
Ordering rules e.g. "this option can only be set after this option" can also be implemented in the same way I think.
One needs to think a little bit more to be able to display in a human understandable way what's wrong when the check rules don't evaluate to true, in the code snippet above we just display the whole rule in text. The user can already subdivide the rules that are not related to make it better: in my example above, I could write this instead:
auto rule1 = (Count(Option("input")) == 1);
auto rule2 = (Count(Option("output")) == 2);
cxxopts::rules::enforce({rule1, rule2}, parsing);
Just leaving this here maybe you guys find it interesting.
The text was updated successfully, but these errors were encountered:
After skimming through #73 #44 and #35, where the main issues from the devs seems to be this one
I have a suggestion that should please both parties (the developers and the users)
A simple and elegant way to handle "required", "optional" and actually any complex rule is to implement template expressions
Here's a small working example that handles constraints of type "option 'foo' must appear exactly once and option 'bar' exactly twice" :
After implementing the
or
,not
,xor
,nand
boolean operations, and all the comparison operations>
,>=
... on theCount
class. We get a great deal of flexibility: rules like "this option can only be used this other one is set ..." can be implemented just with this.Ordering rules e.g. "this option can only be set after this option" can also be implemented in the same way I think.
One needs to think a little bit more to be able to display in a human understandable way what's wrong when the check rules don't evaluate to true, in the code snippet above we just display the whole rule in text. The user can already subdivide the rules that are not related to make it better: in my example above, I could write this instead:
Just leaving this here maybe you guys find it interesting.
The text was updated successfully, but these errors were encountered: