aboutsummaryrefslogtreecommitdiffstats
path: root/task
diff options
context:
space:
mode:
authorRoy Sommer <illBeRoy@users.noreply.github.com>2020-01-02 19:25:03 +0200
committerGitHub <noreply@github.com>2020-01-02 19:25:03 +0200
commit81b17bde80cff6765f9c419965ea93d80814614f (patch)
treec63f4ee8a615bafbb735820388993cfa4635159d /task
parentupdated pytoml (diff)
parentadded support for passing arguments into taskipy tasks (diff)
downloadtaskipy2-81b17bde80cff6765f9c419965ea93d80814614f.zip
Merge pull request #2 from illBeRoy/pass-arguments-to-task
Support Passing Command Line Arguments Into Tasks
Diffstat (limited to '')
-rwxr-xr-xtaskipy/cli.py3
-rw-r--r--taskipy/run.py5
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)