myke.task¶
Functions for registering tasks with myke.
Functions¶
add_tasks ¶
add_tasks(*args: 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: 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')
shell_task ¶
shell_task(func: Callable[..., str | Sequence[str]] | None = None, *, name: str | None = None, parents: str | tuple[str] | None = None, capture_output: bool | None = False, echo: bool | None = True, check: bool | None = True, cwd: str | None = None, env: dict[str, str] | None = None, env_update: dict[str, str | None] | None = None, timeout: float | None = None, executable: str | None = None) -> Callable[..., CompletedProcess[bytes | str]] | Callable[..., Callable[..., CompletedProcess[bytes | str]]]
Function decorator to register shell commands with myke.
myke expects the function to return a string of one or more shell-commands,
and will invoke the commands using myke.run(..., shell=True)
.
PARAMETER | DESCRIPTION |
---|---|
func
|
...
TYPE:
|
name
|
name of the command.
TYPE:
|
parents
|
optional parents for the command.
TYPE:
|
capture_output
|
...
TYPE:
|
echo
|
...
TYPE:
|
check
|
...
TYPE:
|
cwd
|
...
TYPE:
|
env
|
...
TYPE:
|
env_update
|
...
TYPE:
|
timeout
|
...
TYPE:
|
executable
|
...
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Callable[..., CompletedProcess[bytes | str]] | Callable[..., Callable[..., CompletedProcess[bytes | str]]]
|
... |
Examples:
>>> from myke import shell_task
...
>>> @shell_task
... def say_hello(name):
... return f"echo 'Hello {name}.'"
...
>>> @shell_task
... def say_goodbye(name):
... return f"echo 'Goodbye {name}.'"
...
task ¶
task(func: Callable[..., Any] | None = None, *, name: str | None = None, parents: str | tuple[str | yapx.Command, ...] | None = None, shell: bool = False) -> 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:
|
shell
|
if True, act as
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
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}.')
...