aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEugene Triguba <eugenetriguba@gmail.com>2023-04-22 22:15:42 -0400
committerEugene Triguba <eugenetriguba@gmail.com>2023-04-22 22:15:42 -0400
commitbf0e446d093bff84af09410d0240e47dcf34f505 (patch)
tree85838c735cd787584b128ecbb7d1fb826510d533
parentFix type hints (diff)
downloadtaskipy2-bf0e446d093bff84af09410d0240e47dcf34f505.zip
Remove custom IO
-rwxr-xr-xtaskipy/cli.py9
-rw-r--r--taskipy/io.py11
-rw-r--r--taskipy/list.py5
-rw-r--r--taskipy/task_runner.py5
4 files changed, 7 insertions, 23 deletions
diff --git a/taskipy/cli.py b/taskipy/cli.py
index a050146..5b18693 100755
--- a/taskipy/cli.py
+++ b/taskipy/cli.py
@@ -4,7 +4,6 @@ import sys
from pathlib import Path
from typing import List, Union
-from taskipy.io import AbstractIO, AppIO
from taskipy.exceptions import TaskipyError, InvalidUsageError
from taskipy.task_runner import TaskRunner
@@ -16,14 +15,12 @@ def main():
def run(
args: List[str],
- io: AbstractIO = AppIO(), # pylint: disable=C0103
cwd: Union[str, Path, None] = None
) -> int:
"""Run the taskipy CLI programmatically.
Args:
args: The arguments passed to the taskipy CLI.
- io: The IO to use for outputting to the console.
cwd: The working directory to run the task in. If not
provided, defaults to the current working directory.
@@ -44,7 +41,7 @@ def run(
runner = TaskRunner(cwd)
if parsed_args.list:
- runner.list(io)
+ runner.list()
return 0
if parsed_args.name is None:
@@ -52,10 +49,10 @@ def run(
return runner.run(parsed_args.name, parsed_args.args)
except TaskipyError as e:
- io.write_line(str(e))
+ print(e)
return e.exit_code
except Exception as e:
- io.write_line(str(e))
+ print(e)
return 1
diff --git a/taskipy/io.py b/taskipy/io.py
deleted file mode 100644
index 5de35ee..0000000
--- a/taskipy/io.py
+++ /dev/null
@@ -1,11 +0,0 @@
-import abc
-
-class AbstractIO(abc.ABC):
- @abc.abstractmethod
- def write_line(self, line: str) -> None:
- pass
-
-
-class AppIO(AbstractIO):
- def write_line(self, line: str) -> None:
- print(line)
diff --git a/taskipy/list.py b/taskipy/list.py
index 2978fb0..04d683b 100644
--- a/taskipy/list.py
+++ b/taskipy/list.py
@@ -3,7 +3,6 @@ import textwrap
import colorama # type: ignore
from typing import Iterable, Optional
-from taskipy.io import AbstractIO
from taskipy.task import Task
from taskipy.exceptions import EmptyTasksSectionError
@@ -16,7 +15,7 @@ class TasksListFormatter:
self.__tasks = tasks
colorama.init()
- def print(self, io: AbstractIO, line_width: Optional[int] = None): # pylint: disable=C0103
+ def print(self, line_width: Optional[int] = None):
if not line_width:
line_width = shutil.get_terminal_size().columns
@@ -34,7 +33,7 @@ class TasksListFormatter:
desc_col_text = '\n'.join(textwrap.wrap(desc_text,
width=desc_col_width,
subsequent_indent=desc_col_wrap_indent))
- io.write_line(f'{self.__highlight(tasks_col_text)} {desc_col_text}')
+ print(f'{self.__highlight(tasks_col_text)} {desc_col_text}')
def __highlight(self, text: str):
return f'{colorama.Fore.CYAN}{text}{colorama.Style.RESET_ALL}'
diff --git a/taskipy/task_runner.py b/taskipy/task_runner.py
index d115dd7..1a46a4a 100644
--- a/taskipy/task_runner.py
+++ b/taskipy/task_runner.py
@@ -9,7 +9,6 @@ from typing import Callable, Dict, List, Tuple, Union, Optional
import psutil # type: ignore
from taskipy.exceptions import CircularVariableError, TaskNotFoundError, MalformedTaskError
-from taskipy.io import AbstractIO
from taskipy.list import TasksListFormatter
from taskipy.pyproject import PyProject
from taskipy.task import Task
@@ -27,10 +26,10 @@ class TaskRunner:
self.__working_dir = working_dir
self.__project = PyProject(working_dir)
- def list(self, io: AbstractIO): # pylint: disable=C0103
+ def list(self): # pylint: disable=C0103
"""lists tasks to stdout"""
formatter = TasksListFormatter(self.__project.tasks.values())
- formatter.print(io)
+ formatter.print()
def run(self, task_name: str, args: List[str]) -> int:
pre_command, command, post_command = self.__get_formatted_commands(task_name)