Skip to content

Group

clap.Group dataclass

Group(
    title: str,
    about: Optional[str] = None,
    long_about: Optional[str] = None,
    conflict_handler: Optional[str] = None,
)

Family of related arguments.

Example:

from pathlib import Path

import clap
from clap import Group, arg

@clap.command
class Cli(clap.Parser):
    output_options = Group("Output Options")
    """Configure output settings."""
    output_dir: Path = arg(long="output", group=output_options, value_name="DIR")
    """Path to output directory"""

Attributes:

about class-attribute instance-attribute

about: Optional[str] = None

The group's description for the short help (-h).

If Group.long_about is not specified, this message will be displayed for --help.

conflict_handler class-attribute instance-attribute

conflict_handler: Optional[str] = None

The strategy for resolving conflicting optionals within this group.

This is forwarded to argparse.

long_about class-attribute instance-attribute

long_about: Optional[str] = None

The group's description for the long help (--help).

If not set, Group.about will be used for long help in addition to short help (-h).

title instance-attribute

title: str

The title for the argument group in the help output.