diff options
| author | Roy Sommer <royso@wix.com> | 2020-01-02 19:12:08 +0200 |
|---|---|---|
| committer | Roy Sommer <royso@wix.com> | 2020-01-02 19:12:08 +0200 |
| commit | b7c1dc794d4e4faa068594139e945fbeac7b02b5 (patch) | |
| tree | c63f4ee8a615bafbb735820388993cfa4635159d /task | |
| parent | updated pytoml (diff) | |
| download | taskipy2-b7c1dc794d4e4faa068594139e945fbeac7b02b5.zip | |
added support for passing arguments into taskipy tasks
Diffstat (limited to '')
| -rwxr-xr-x | taskipy/cli.py | 3 | ||||
| -rw-r--r-- | taskipy/run.py | 5 |
2 files changed, 5 insertions, 3 deletions
diff --git a/taskipy/cli.py b/taskipy/cli.py index a450db0..f37d5f6 100755 --- a/taskipy/cli.py +++ b/taskipy/cli.py @@ -5,9 +5,10 @@ from taskipy.run import run_task def main(): parser = argparse.ArgumentParser(prog='task', description='runs a task specified in your pyproject.toml under [tool.taskipy.tasks]') parser.add_argument('name', help='name of the task') + parser.add_argument('args', nargs=argparse.REMAINDER, help='arguments to pass to the task') args = parser.parse_args() - run_task(args.name) + run_task(args.name, args.args) if __name__ == '__main__': main() diff --git a/taskipy/run.py b/taskipy/run.py index b8ae4ab..ff2db44 100644 --- a/taskipy/run.py +++ b/taskipy/run.py @@ -5,7 +5,7 @@ import toml from os import path from typing import List -def run_task(task_name: str, cwd=os.curdir): +def run_task(task_name: str, args: List[str], cwd=os.curdir): def run_commands_and_bail_on_first_fail(cmds: List[str]) -> int: for cmd in cmds: p = subprocess.Popen(cmd, shell=True, cwd=cwd) @@ -34,7 +34,8 @@ def run_task(task_name: str, cwd=os.curdir): try: task = tasks[task_name] - commands.append(task) + command_with_passed_args = ' '.join([task] + args) + commands.append(command_with_passed_args) except: print(f'could not find task "{task_name}""') sys.exit(127) |