diff --git a/pyproject.toml b/pyproject.toml index d770eea..303c948 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -125,7 +125,7 @@ skips = ["B102", "B701", "B507", "B601"] [tool.vulture] exclude = ["tests"] ignore_decorators = [] -ignore_names = [] +ignore_names = ["verbose", "dry_run"] make_whitelist = true min_confidence = 80 paths = ["src/makim/"] diff --git a/src/makim/cli/__init__.py b/src/makim/cli/__init__.py index 1f4b685..ac9d2bd 100644 --- a/src/makim/cli/__init__.py +++ b/src/makim/cli/__init__.py @@ -126,31 +126,6 @@ def run_app() -> None: for task_name, task_data in group_data.get('tasks', {}).items(): tasks[f'{group_name}.{task_name}'] = task_data - # add dummy test data: - """ - scheduler: - build: - schedule: "* * * * *" # hourly, daily, weekly, monthly, yearly - task: main.build - args: - clean: true - clean: - schedule: "* * * * *" - task: main.clean - """ - - makim.global_data['scheduler'] = { - 'build': { - 'schedule': '* * * * *', - 'task': 'main.build', - 'args': {'clean': True}, - }, - 'clean': { - 'schedule': '* * * * *', - 'task': 'main.clean', - }, - } - # Add dynamically cron commands to Typer app if 'scheduler' in makim.global_data: typer_cron = typer.Typer( diff --git a/src/makim/cli/auto_generator.py b/src/makim/cli/auto_generator.py index f59a5ad..bd08bd8 100644 --- a/src/makim/cli/auto_generator.py +++ b/src/makim/cli/auto_generator.py @@ -261,15 +261,7 @@ def create_dynamic_command_cron( args : dict The command arguments and options. """ - args_str = create_args_string(args) args_param_list = [f'"task": "{name}"'] - - args_data = cast(Dict[str, Dict[str, str]], args.get('args', {})) - - for arg, arg_details in args_data.items(): - arg_clean = arg.replace('-', '_') - args_param_list.append(f'"--{arg}": {arg_clean}') - args_param_str = '{' + ','.join(args_param_list) + '}' group_name = 'cron' @@ -279,22 +271,9 @@ def create_dynamic_command_cron( rich_help_panel=group_name, ) - function_code = f'def dynamic_command({args_str}):\n' - - # handle interactive prompts - for arg, arg_details in args_data.items(): - arg_clean = arg.replace('-', '_') - if arg_details.get('interactive', False): - function_code += f' if {arg_clean} is None:\n' - function_code += f" {arg_clean} = click.prompt('{arg}')\n" - + function_code = 'def dynamic_command():\n' function_code += f' makim.run({args_param_str})\n' local_vars: dict[str, Any] = {} exec(function_code, globals(), local_vars) - dynamic_command = decorator(local_vars['dynamic_command']) - - # Apply Click options to the Typer command - if 'args' in args: - options_data = cast(Dict[str, Dict[str, Any]], args.get('args', {})) - dynamic_command = apply_click_options(dynamic_command, options_data) + decorator(local_vars['dynamic_command'])