Commands
fyt.utils.commands
¶
command(function)
¶
Decorator that turns a function into a CLI command.
The decorated function must have at least one parameter (after self,
if it is a method) whose type annotation is a config class with a
from_yaml class method. At runtime the decorator parses
--config <path> from the CLI, loads the YAML into the annotated
config class, and calls the original function with it.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
function
|
Callable
|
The function to decorate. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Callable |
Callable
|
The decorated function that can be called from the CLI. |
Raises:
| Type | Description |
|---|---|
MissingCommandParameterError
|
If the function has no parameters (after dropping |
MissingCommandParameterAnnotationError
|
If the first parameter has no type annotation. |