Skip to contents

An ArgumentGroup R6 object wraps a Python argparse argument group. Objects of this class are returned by the add_argument_group() method of Parser objects. Argument groups are used to group related arguments together in the help message.

Super class

Group -> ArgumentGroup

Methods

Inherited methods


ArgumentGroup$add_mutually_exclusive_group()

Create a mutually exclusive group. Only one of the arguments added to the group may be present on the command line.

Usage

ArgumentGroup$add_mutually_exclusive_group(required = FALSE)

Arguments

required

If TRUE then exactly one of the arguments in the group must be present on the command line.

Returns

A MutuallyExclusiveGroup object.

Examples

if (argparse:::detects_python()) {
  parser <- ArgumentParser(prog = "PROG", add_help = FALSE)
  group <- parser$add_argument_group("group")
  group$add_argument("--foo", help = "foo help")
  group$add_argument("bar", help = "bar help")
  parser$print_help()
}
#> usage: PROG [--foo FOO] bar
#> 
#> group:
#>   --foo FOO  foo help
#>   bar        bar help