MutexGroup
clap.MutexGroup
dataclass
Create a mutually exclusive group of arguments.
It will be ensured that only one of the arguments in the mutually
exclusive group is present on the command line. This is useful for
options that conflict with each other, such as --verbose and --quiet.
Example:
import clap
from clap import MutexGroup
@clap.command
class Cli(clap.Parser):
loglevel = MutexGroup()
verbose: bool = arg(long, mutex=loglevel)
quiet: bool = arg(long, mutex=loglevel)
Attributes:
-
parent(Optional[Group]) –The parent argument group to add this mutually exclusive group to.
-
required(bool) –Whether at least one of the mutually exclusive arguments must be present.
parent
class-attribute
instance-attribute
The parent argument group to add this mutually exclusive group to.
If None, the group will be added directly to the parser.
required
class-attribute
instance-attribute
required: bool = False
Whether at least one of the mutually exclusive arguments must be present.