Skip to main content

DjangoHelpFormatter

Customized formatter so that command-specific arguments appear in the --help output before arguments common to all commands.

Attributes

AttributeTypeDescription
show_lastset = {"--version", "--verbosity", "--traceback", "--settings", "--pythonpath", "--no-color", "--force-color", "--skip-checks"}A set of command-line option strings that are prioritized to appear at the end of the help output to ensure command-specific arguments are displayed first.

Methods


add_usage()

@classmethod
def add_usage(
usage: string,
actions: list,
*args: any,
**kwargs: any
)

Adds the usage section to the help message, ensuring that the displayed arguments follow the custom reordering logic.

Parameters

NameTypeDescription
usagestringThe usage string or template to be formatted.
actionslistThe list of argparse actions to include in the usage synopsis.
*argsanyPositional arguments passed to the parent HelpFormatter.add_usage method.
**kwargsanyKeyword arguments passed to the parent HelpFormatter.add_usage method.

add_arguments()

@classmethod
def add_arguments(
actions: list
)

Adds the arguments section to the help output using a reordered list of actions to prioritize command-specific flags.

Parameters

NameTypeDescription
actionslistThe list of argparse actions to be formatted into the arguments section of the help text.