-
Notifications
You must be signed in to change notification settings - Fork 842
ArgParser: Add mutually exclusive option groups #12621
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
base: master
Are you sure you want to change the base?
Conversation
Implement support for mutually exclusive option groups in ArgParser, allowing options that cannot be used together to be properly validated and documented. This feature is useful for conflicting options like --verbose/--quiet or --enable/--disable, where only one option from a group should be specified at a time. Unit tests coverage.
| In this case, `subinit` is the subcommand of `init` and `--initoption` is a switch of command `remove`. | ||
|
|
||
| Mutually Exclusive Groups |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AI generated.
|
[approve ci autest] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool feature! I have a couple of issues and suggestions.
Thanks!
include/tscore/ArgParser.h
Outdated
| static void set_test_mode(bool test = true); | ||
|
|
||
| // When true, do_exit() throws instead of calling exit() | ||
| static thread_local bool _test_mode; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this need to be thread_local? Could it not just be a member variable on this instance?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was under the impression that catch2 can run tests in parallel, was trying to prevent that, but looking around seems it's not(in this case at least). I'll remove the thread_local.
Also, I thought about as member of ArgParser, but then I would need to pass an instance(ptr) of ArgParser to the Command class as most(if not all) of the do_exit calls are made from that(Command) class.
Implement support for mutually exclusive option groups in ArgParser, allowing options that cannot be used together to be properly validated and documented.
This feature is useful for conflicting options like
--verbose/--quietor--enable/--disable, where only one option from a group should be specified at a time.fixes #12605