A MutuallyExclusiveGroup R6 object wraps a Python argparse mutually
exclusive group.
Objects of this class are returned by the add_mutually_exclusive_group()
method of Parser and ArgumentGroup objects.
Only one of the arguments added to a mutually exclusive group may be
present on the command line.
Unlike an ArgumentGroup, a mutually exclusive group can't contain nested groups (Python 3.14 and later no longer allow this).
Super class
Group -> MutuallyExclusiveGroup
Examples
if (argparse:::detects_python()) {
parser <- ArgumentParser(prog = "PROG")
group <- parser$add_mutually_exclusive_group()
group$add_argument("--foo", action = "store_true")
group$add_argument("--bar", action = "store_false")
parser$parse_args("--foo")
}
#> $bar
#> [1] TRUE
#>
#> $foo
#> [1] TRUE
#>