aboutsummaryrefslogtreecommitdiffstats
path: root/poetry_plugin_taskipy/commands.py
blob: f4d8656ed4ca62862679afedbd3943938e91f153 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import taskipy
from cleo.commands.command import Command
from cleo.helpers import argument, option


class TaskipyCommand(Command):
    name = "task"
    description = "taskipy - the complementary task runner for python"
    options = [option("list", "l", "Show list of available tasks.")]
    arguments = [
        argument("name", "Name of the task.", optional=True),
        argument(
            "args",
            "Arguments to pass to the task.",
            optional=True,
            multiple=True,
            default=[],
        ),
    ]

    def handle(self) -> int:
        command = ""

        if self.argument("name"):
            command += self.argument("name")

        if self.argument("args"):
            command += " "
            command += " ".join(self.argument("args"))

        return taskipy.run(command)