climate.flags

Useful utilities for command-line arguments.

Functions

add_arg(*args, **kwargs) Add an argparse argument.
add_arg_group(*args, **kwargs) Add an argparse argument group.
add_command(*args, **kwargs) Add an argparse command parser.
add_mutex_arg_group(*args, **kwargs) Add a mutually-exclusive argparse group.
annotate(*args, **kwargs) Return a decorator for plac-style argument annotations.
parse_args(**overrides) Parse command-line arguments, overriding with keyword arguments.

Classes

Parser(*args, **kwargs) This class provides some sane default command-line argument behaviors.
class climate.flags.Parser(*args, **kwargs)[source]

This class provides some sane default command-line argument behaviors.

In particular, the help formatter includes default values, and arguments can be loaded from files. Files can contain arguments in two ways: one per line, or many-per-line. For one-per-line arguments, spaces etc. are preserved, while for many-per-line arguments, the line must start with a dash, and multiple arguments are split on whitespace. In all cases, shell-style comments are removed from the file before processing.

convert_arg_line_to_args(line)[source]

Remove # comments and blank lines from arg files.

climate.flags.add_arg(*args, **kwargs)[source]

Add an argparse argument.

climate.flags.add_arg_group(*args, **kwargs)[source]

Add an argparse argument group.

Returns:An argparse argument group object.
climate.flags.add_command(*args, **kwargs)[source]

Add an argparse command parser.

The name of the command will be stored in the “command_name” argparse variable.

Returns:An argparse command parser object.
climate.flags.add_mutex_arg_group(*args, **kwargs)[source]

Add a mutually-exclusive argparse group.

Returns:A mutually-exclusive argparse argument group object.
climate.flags.annotate(*args, **kwargs)[source]

Return a decorator for plac-style argument annotations.

climate.flags.parse_args(**overrides)[source]

Parse command-line arguments, overriding with keyword arguments.

Returns:

args :

The command-line argument namespace object.

kwargs :

A dictionary version of the command-line arguments.

Related Topics

This Page