Skip to content

Core

clap.core.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,
    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,
    choices_help: Optional[dict[str, str]] = None,
    required: Optional[bool] = None,
    deprecated: Optional[bool] = None,
    dest: Optional[str] = None,
    extend_default: Optional[Any] = None,
)

Attributes:

aliases class-attribute instance-attribute

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

Flags in addition to short and long.

extend_default class-attribute instance-attribute

extend_default: Optional[Any] = None

argparse has a "bug" where the values get appended to the default value list if the extend action is used. This is a workaround for that.

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.

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.core.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.

Alias: long.

Short class-attribute instance-attribute

Short = auto()

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

Alias: short.

clap.core.Command dataclass

Command(
    name: str,
    aliases: Sequence[str] = list(),
    usage: Optional[str] = None,
    author: 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,
    field_to_arg: dict[str, Arg] = dict(),
    field_to_group_cls: dict[str, type] = dict(),
    group_to_args: dict[Group, list[Arg]] = dict(),
    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.