diplomat.utils.cli_toolsΒΆ

Provides functions for turning typecaster annotated functions into CLI commands.

Module Attributes

Flag

Custom type caster type that represents a boolean flag argument on the command line (true/false doesn't need to be specified).

Functions

allow_arbitrary_flags(func)

Decorator: Allow arbitrary CLI flags on a typecaster function.

build_full_parser(function_tree, parent_parser)

Build an entire CLI interface with subcommands from a tree of typecaster functions.

clear_extra_cli_args_and_copy(func)

Create a copy of a typecaster function, with all CLI settings cleared.

extra_cli_args(config_spec[, auto_cast, ...])

A decorator for attaching additional CLI arguments to an auto-cli function...

func_args_to_config_spec(func, caller_func)

Convert extra typecaster function arguments to a ConfigSpec.

func_to_command(func, parser[, allow_short_form])

Convert a typecaster function into an argparse command (CLI command).

get_summary_from_doc_str(doc_str)

Extracts the summary for a command from a function's doc string.

positional_argument_count(amt)

Decorator: Mark the first n arguments to this typecaster function as positional.

Classes

CLIEngine(parent_parser)

Represents a CLI program.

ComplexParsingWrapper(run_func, correctors, ...)

Internal: Parses arguments for a single diplomat sub-command.

YAMLArgHelpFormatter(prog[, ...])

Internal: A Subclass of argparse's HelpFormatter class, that correctly formats arguments when printing a help string to the CLI.

Exceptions

CLIError

A custom exception thrown when an error occurs when attempting to parse user CLI inputs.