diff --git a/hack/bundle-automation/generate-shell.py b/hack/bundle-automation/generate-shell.py index 009278435..8a06175b5 100644 --- a/hack/bundle-automation/generate-shell.py +++ b/hack/bundle-automation/generate-shell.py @@ -132,13 +132,14 @@ def cleanup_script_dependencies(copied_files): shutil.rmtree(utils_dest) logging.debug(f"Removed utils directory") -def prepare_and_execute(operation, operation_data, args): +def prepare_and_execute(operation, operation_data, args, extra_args): """Prepares and executes the operation based on the provided operation data. Args: operation (_type_): _description_ operation_data (_type_): _description_ args (_type_): _description_ + extra_args (_type_): _description_ """ logging.info(f"Executing operator: {operation}") @@ -161,6 +162,10 @@ def prepare_and_execute(operation, operation_data, args): if args.config: operations_args += " --config {}".format(args.config) + # Add any extra arguments passed through + if extra_args: + operations_args += " " + " ".join(extra_args) + # Execute the script execute_script(script_file, operations_args) @@ -188,11 +193,12 @@ def execute_script(script_path, args): logging.error(f"Script {script_path.name} failed with exit code {e.returncode}") sys.exit(e.returncode) -def main(args): +def main(args, extra_args): """_summary_ Args: args (_type_): _description_ + extra_args (_type_): _description_ """ logging.basicConfig(level=logging.INFO) @@ -205,7 +211,7 @@ def main(args): for operation, operation_data in SUPPORTED_OPERATIONS.items(): if getattr(args, operation.replace('-', '_'), False): - prepare_and_execute(operation, operation_data, args) + prepare_and_execute(operation, operation_data, args, extra_args) break end_time = time.time() # Record the end time and log the duration of the script execution @@ -237,5 +243,6 @@ def main(args): parser.set_defaults(bundle=False, commit=False, lint=False) # Parse command-line arguments and call the main function - args = parser.parse_args() - main(args) + # Use parse_known_args to capture unknown arguments and pass them through + args, extra_args = parser.parse_known_args() + main(args, extra_args)