import argparse
import os
def bootstrap_script_paths(script_path, flags=None):
"""
Generates a list of bootstrap script paths based on a base script path
and optional flags.
Args:
script_path (str): The base path to the script.
flags (list, optional): A list of flags to apply. Defaults to None.
Returns:
list: A list of file paths to the bootstrapped scripts. Returns an empty list if script_path is invalid.
"""
if not os.path.exists(script_path):
print(f"Error: Script path '{script_path}' does not exist.")
return []
bootstrapped_paths = []
if flags is None:
bootstrapped_paths.append(script_path)
else:
for flag in flags:
new_path = os.path.join(os.path.dirname(script_path), script_path + "_" + flag)
bootstrapped_paths.append(new_path)
return bootstrapped_paths
if __name__ == '__main__':
parser = argparse.ArgumentParser(description="Generate bootstrapped script paths.")
parser.add_argument("script_path", help="The base script path.")
parser.add_argument("-f", "--flags", nargs="+", help="List of flags to apply.")
args = parser.parse_args()
script_path = args.script_path
flags = args.flags
paths = bootstrap_script_paths(script_path, flags)
if paths:
for path in paths:
print(path)
Add your comment