From 3044d57606316fca600d0433e1b4bed6bb66e030 Mon Sep 17 00:00:00 2001 From: Eugene Triguba Date: Sat, 22 Apr 2023 22:24:48 -0400 Subject: Add proper handling of poetry global directory option --- poetry_plugin_taskipy/commands.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/poetry_plugin_taskipy/commands.py b/poetry_plugin_taskipy/commands.py index 4e80fd8..8b9e837 100644 --- a/poetry_plugin_taskipy/commands.py +++ b/poetry_plugin_taskipy/commands.py @@ -1,6 +1,8 @@ -import taskipy +import pathlib + from cleo.commands.command import Command from cleo.helpers import argument, option +from taskipy import cli as taskipy_cli class TaskipyCommand(Command): @@ -21,13 +23,17 @@ class TaskipyCommand(Command): def handle(self) -> int: arguments = [] + cwd = pathlib.Path.cwd() + if self.option("directory"): + cwd = pathlib.Path(self.option("directory")).resolve() + + if self.option("list"): + arguments.append("--list") + if self.argument("name"): arguments.append(self.argument("name")) if self.argument("args"): arguments.extend(self.argument("args")) - if self.option("list"): - arguments.append("--list") - - return taskipy.run(arguments) + return taskipy_cli.run(arguments, cwd=cwd) -- cgit v1.2.3