Skip to main content

Module argparse

Module argparse 

Source
Expand description

The part of Python’s argparse (CPython 3.13) that the fontTools command lines use: parsing the arguments as ArgumentParser.parse_args does, with its error messages.

The arguments are declared as with add_argument (Argument): options with abbreviable long names and combinable short names, positional arguments with nargs, type=float/type=int values, mutually exclusive groups (Argument::group). parse follows _parse_known_args: the positional arguments are matched against the pattern of the arguments between the options, as argparse does with regular expressions.

The help and usage texts are not generated: Command holds them as fontTools prints them, and prints them as argparse does (print_help, error), through program_text.

Structs§

Argument
An argument (add_argument).
Command
A command line declared with argparse: its prog, its module (for program_text), its help text as argparse prints it, and its arguments.
Parsed
The parsed command line, by Argument::key.
Seen
The values of an argument given on the command line.

Enums§

Action
What an argument does when it is given (action=).
Nargs
How many values an argument takes (nargs=).
Ty
The type of an argument’s values, checked when they are taken.

Functions§

parse
Parses args as ArgumentParser.parse_args does, for the declared arguments; required_groups are the mutually exclusive groups with required=True. Err holds the message of parser.error.
parse_float
type=float: the value, or the message of the error for the argument display (see Argument::display).
parse_int
type=int: the value, or the message of the error for the argument display (see Argument::display).