Skip to content

Models

clap.models.Arg dataclass

Arg(
    short: Optional[Union[AutoFlag, str]] = None,
    long: Optional[Union[AutoFlag, str]] = None,
    help: Optional[str] = None,
    long_help: Optional[str] = None,
    value_name: Optional[str] = None,
    aliases: Sequence[str] = list(),
    ty: Optional[Base] = None,
    group: Optional[Group] = None,
    mutex: Optional[MutexGroup] = None,
    action: Optional[Union[ArgAction, type]] = None,
    num_args: Optional[NargsType] = None,
    default_missing_value: Optional[Any] = None,
    default_value: Optional[Any] = None,
    choices: Optional[Sequence[str]] = None,
    required: Optional[bool] = None,
    deprecated: Optional[bool] = None,
    dest: Optional[str] = None,
)

Attributes:

aliases class-attribute instance-attribute

aliases: Sequence[str] = field(default_factory=list)

Flags in addition to short and long.

group class-attribute instance-attribute

group: Optional[Group] = None

The group containing the argument.

long class-attribute instance-attribute

long: Optional[Union[AutoFlag, str]] = None

The long flag.

mutex class-attribute instance-attribute

mutex: Optional[MutexGroup] = None

The mutually exclusive group containing the argument.

short class-attribute instance-attribute

short: Optional[Union[AutoFlag, str]] = None

The short flag.

ty class-attribute instance-attribute

ty: Optional[Base] = None

Stores type information for the argument.

clap.models.Group dataclass

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

clap.models.MutexGroup dataclass

MutexGroup(
    parent: Optional[Group] = None, required: bool = False
)

clap.models.AutoFlag

Bases: Enum

Attributes:

  • Long

    Generate long from the case-converted field name.

  • Short

    Generate short from the first character in the case-converted field name.

Long class-attribute instance-attribute

Long = auto()

Generate long from the case-converted field name.

Short class-attribute instance-attribute

Short = auto()

Generate short from the first character in the case-converted field name.

clap.models.Command dataclass

Command(
    name: str,
    aliases: Sequence[str] = list(),
    usage: Optional[str] = None,
    version: Optional[str] = None,
    long_version: Optional[str] = None,
    about: Optional[str] = None,
    long_about: Optional[str] = None,
    before_help: Optional[str] = None,
    before_long_help: Optional[str] = None,
    after_help: Optional[str] = None,
    after_long_help: Optional[str] = None,
    subcommand_help_heading: str = "Commands",
    subcommand_value_name: str = "COMMAND",
    color: Optional[ColorChoice] = None,
    styles: Optional[Styles] = None,
    help_template: Optional[str] = None,
    max_term_width: Optional[int] = None,
    propagate_version: bool = False,
    disable_version_flag: bool = False,
    disable_help_flag: bool = False,
    prefix_chars: str = "-",
    fromfile_prefix_chars: Optional[str] = None,
    conflict_handler: Optional[str] = None,
    allow_abbrev: Optional[bool] = None,
    exit_on_error: Optional[bool] = None,
    deprecated: Optional[bool] = None,
    args: dict[str, Arg] = dict(),
    groups: dict[Group, list[Arg]] = dict(),
    mutexes: defaultdict[
        MutexGroup, list[Arg]
    ] = lambda: defaultdict(list)(),
    subcommand_class: Optional[type] = None,
    subcommands: dict[str, Self] = dict(),
    subcommand_dest: Optional[str] = None,
    subparser_dest: Optional[str] = None,
    subcommand_required: bool = False,
)

Attributes:

subcommand_class class-attribute instance-attribute

subcommand_class: Optional[type] = None

Contains the class if it is a subcommand.