From c74229c9c8fed6cc5b3dcc71dd1f1f376ad3e86b Mon Sep 17 00:00:00 2001 From: Ivan Ogasawara Date: Fri, 29 Nov 2024 01:07:12 -0400 Subject: [PATCH] fix usage of the makim object inside the generated code --- src/makim/cli/auto_generator.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/makim/cli/auto_generator.py b/src/makim/cli/auto_generator.py index 05b0553..6b39471 100644 --- a/src/makim/cli/auto_generator.py +++ b/src/makim/cli/auto_generator.py @@ -242,7 +242,10 @@ def create_dynamic_command( function_code += f' makim.run({args_param_str})\n' local_vars: dict[str, Any] = {} - exec(function_code, globals(), local_vars) + global_vars: dict[str, Any] = globals() + global_vars['makim'] = makim + + exec(function_code, global_vars, local_vars) dynamic_command = decorator(local_vars['dynamic_command']) # Apply Click options to the Typer command @@ -278,5 +281,8 @@ def create_dynamic_command_cron( function_code += f' makim.run({args_param_str})\n' local_vars: dict[str, Any] = {} - exec(function_code, globals(), local_vars) + global_vars: dict[str, Any] = globals() + global_vars['makim'] = makim + + exec(function_code, global_vars, local_vars) decorator(local_vars['dynamic_command'])