From c174e1f128e41b8d1635596be97c29e9cbda8a80 Mon Sep 17 00:00:00 2001 From: Yuvraj Date: Thu, 17 Oct 2024 04:18:51 +0530 Subject: [PATCH] added run command --- pytask/taskcli.py | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/pytask/taskcli.py b/pytask/taskcli.py index 83d0717..8f2914d 100644 --- a/pytask/taskcli.py +++ b/pytask/taskcli.py @@ -8,7 +8,8 @@ import tempfile import json import fnmatch - +import sys +import importlib from typing import TypedDict, List, Dict from enum import Enum @@ -110,6 +111,21 @@ def get_function_info(node: ast.FunctionDef) -> Dict[str, Any]: return configs + +@click.command() +@click.argument('task_name', type=str) +def run(task_name: str) -> None: + """ + Run a specified task by name. + + Args: + task_name (str): The name of the task to run. + """ + # task_module = importlib.import_module(".") + # task_function = getattr(task_module, task_name) + # task_function() + print(f"Task '{task_name}' executed.") # Placeholder for task execution logic + @click.group(invoke_without_command=True) @click.argument('dir', type=click.Path(exists=True), nargs=1, required=False, default='.') @click.option('--image', '-i', help='Specify a custom image') @@ -217,5 +233,7 @@ def process_file(file_path: str, custom_image: str = None) -> None: logger.info(f"Stored task and workflow protos in {output_filename}") +cli.add_command(run) # Register the new command + if __name__ == '__main__': cli()