Skip to content

Loader

Load a Click command object from a file system path.

CLASS DESCRIPTION
LoadError

Raised when a Click command cannot be loaded.

FUNCTION DESCRIPTION
load_command

Load a Click command from a Python file.

Classes

LoadError

Bases: Exception

Raised when a Click command cannot be loaded.

Functions

load_command

load_command(module_path: str, command_name: str = 'cli') -> BaseCommand

Load a Click command from a Python file.

PARAMETER DESCRIPTION
module_path

File system path to the Python module (absolute or relative to cwd).

TYPE: str

command_name

Dotted attribute path on the module, e.g. cli or commands.root.

TYPE: str DEFAULT: 'cli'

RETURNS DESCRIPTION
BaseCommand

The resolved Click command object.

RAISES DESCRIPTION
LoadError

If the file does not exist, the attribute is missing, or the resolved object is not a Click command.