From e0a095571f59f19fecd814781d9a733e3a13ea02 Mon Sep 17 00:00:00 2001 From: Pranav Srinivas Kumar Date: Sat, 4 Nov 2023 15:41:48 -0500 Subject: [PATCH] Updated README to include mutex_args feature --- README.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/README.md b/README.md index 9abd975..0a89e96 100644 --- a/README.md +++ b/README.md @@ -298,6 +298,21 @@ foo@bar:/home/dev/$ ./main --first 1 --second 2 Argument '--second VAR' not allowed with '--first VAR' ``` +The `add_mutually_exclusive_group()` function also accepts a `required` argument, to indicate that at least one of the mutually exclusive arguments is required: + +```cpp +auto &group = program.add_mutually_exclusive_group(true); +group.add_argument("--first"); +group.add_argument("--second"); +``` + +with the following usage will yield an error: + +```console +foo@bar:/home/dev/$ ./main +One of the arguments '--first VAR' or '--second VAR' is required +``` + ### Negative Numbers Optional arguments start with ```-```. Can ```argparse``` handle negative numbers? The answer is yes!