myke.task¶
Functions for registering tasks with myke.
Functions¶
add_tasks ¶
add_tasks(
*args: Union[Callable[..., Any], Task],
**kwargs: Callable[..., Any]
) -> None
Register the given callable(s) with myke.
PARAMETER | DESCRIPTION |
---|---|
*args
|
...
TYPE:
|
**kwargs
|
...
TYPE:
|
RAISES | DESCRIPTION |
---|---|
TaskAlreadyRegisteredError
|
... |
Examples:
import myke
def say_hello(name):
print(f"Hello {name}.")
def say_goodbye(name):
print(f"Goodbye {name}.")
myke.add_tasks(say_hello, say_goodbye)
import_module ¶
import_module(name: str) -> None
Import tasks from the given Python module.
PARAMETER | DESCRIPTION |
---|---|
name
|
name of the module.
TYPE:
|
RAISES | DESCRIPTION |
---|---|
NoTasksFoundError
|
|
Examples:
# import myke
# myke.import_module("python_pkg.python_module")
import_mykefile ¶
import_mykefile(path: Union[str, Path]) -> None
Import tasks from another Mykefile.
PARAMETER | DESCRIPTION |
---|---|
path
|
path to the Mykefile
TYPE:
|
RAISES | DESCRIPTION |
---|---|
NoTasksFoundError
|
|
Examples:
# import myke
# myke.import_mykefile("/path/to/tasks.py")
task ¶
task(
func: Union[Callable[..., Any], None] = None,
*,
name: Union[str, None] = None,
parents: Union[
str, tuple[Union[str, Command], ...], None
] = None
) -> Union[
Callable[..., Any], Callable[..., Callable[..., Any]]
]
Function decorator to register functions with myke.
PARAMETER | DESCRIPTION |
---|---|
func
|
...
TYPE:
|
name
|
name of the command.
TYPE:
|
parents
|
optional parent(s) for the command.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Union[Callable[..., Any], Callable[..., Callable[..., Any]]]
|
... |
Examples:
from myke import task
@task
def say_hello(name):
print(f"Hello {name}.")
@task
def say_goodbye(name):
print(f"Goodbye {name}.")