docs/extending-taskiq/cli.md
You can easily add new subcommands to taskiq. All default subcommands also use this mechanism, since it's easy to use.
At first you need to add a class that implements taskiq.abc.cmd.TaskiqCMD abstract class.
In the exec method, you should parse incoming arguments. But since all CLI arguments to taskiq are shifted you can ignore the args parameter.
Also, you can use your favorite tool to build CLI, like click or typer.
After you have such class, you need to add entrypoint that points to that class.
::: tabs
@tab setuptools setup.py
from setuptools import setup
setup(
# ...,
entry_points={
'taskiq_cli': [
'demo = my_project.cmd:MyCommand',
]
}
)
@tab setuptools pyproject.toml
[project.entry-points.taskiq_cli]
demo = "my_project.cmd:MyCommand"
@tab poetry
[tool.poetry.plugins.taskiq_cli]
demo = "my_project.cmd:MyCommand"
:::
You can read more about entry points in python documentation. The subcommand name is the same as the name of the entry point you've created.
$ taskiq demo --help
usage: demo [-h] [--test TEST]
optional arguments:
-h, --help show this help message and exit
--test TEST My test parameter.
$ taskiq demo --test aaa
Namespace(test='aaa')