Skip to content

Conversation

@brbzull0
Copy link
Contributor

@brbzull0 brbzull0 commented Oct 28, 2025

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.

fixes #12605

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.
@brbzull0 brbzull0 self-assigned this Oct 28, 2025
In this case, `subinit` is the subcommand of `init` and `--initoption` is a switch of command `remove`.

Mutually Exclusive Groups
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AI generated.

@brbzull0 brbzull0 marked this pull request as ready for review October 29, 2025 08:58
@brbzull0 brbzull0 marked this pull request as draft October 29, 2025 11:09
@bneradt
Copy link
Contributor

bneradt commented Oct 29, 2025

[approve ci autest]

@bryancall bryancall requested a review from cmcfarlen November 3, 2025 22:45
Copy link
Contributor

@cmcfarlen cmcfarlen left a 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!

static void set_test_mode(bool test = true);

// When true, do_exit() throws instead of calling exit()
static thread_local bool _test_mode;
Copy link
Contributor

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?

Copy link
Contributor Author

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.

@brbzull0 brbzull0 requested a review from cmcfarlen November 5, 2025 12:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support the creation of a mutually exclusive groups for ArgParser

3 participants