From f0a132b415207e62fd2d256c4d40de8c9cbe6f8f Mon Sep 17 00:00:00 2001 From: badra001 Date: Fri, 16 Jan 2026 10:25:11 -0500 Subject: [PATCH] add --description --- .../sso-tools/sso-create-sc-group.py | 26 ++++++++++++------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/local-app/python-tools/sso-tools/sso-create-sc-group.py b/local-app/python-tools/sso-tools/sso-create-sc-group.py index 7d9cc202..b4854439 100755 --- a/local-app/python-tools/sso-tools/sso-create-sc-group.py +++ b/local-app/python-tools/sso-tools/sso-create-sc-group.py @@ -2,6 +2,7 @@ import argparse import shutil import sys +import os from pathlib import Path from jinja2 import Environment, FileSystemLoader @@ -10,13 +11,15 @@ # 1.0.1: Added shebang, exposed variables to Jinja2 # 1.0.2: Enforced lowercase for group and created_group names # 1.0.3: Added directory existence check and --force flag -__version__ = "1.0.3" +# 1.0.4: Added --description, startup banner, and context exposure +__version__ = "1.0.4" def create_sc_group(): parser = argparse.ArgumentParser(description="Automate file creation from templates.") parser.add_argument("-b", "--business-label", required=True, help="Required business label") parser.add_argument("-a", "--application-label", help="Optional application label") parser.add_argument("-g", "--group", help="Group name (defaults to current directory name)") + parser.add_argument("-d", "--description", help="Description for the group") parser.add_argument("-f", "--force", action="store_true", help="Overwrite existing directory if it exists") parser.add_argument("-v", "--version", action="version", version=f"%(prog)s {__version__}") @@ -31,14 +34,19 @@ def create_sc_group(): else: created_group = f"{args.business_label}-{group_name}".lower() - # 2. Check for existing directory + # 2. Output Startup Banner + script_name = os.path.basename(__file__) + print(f"--- {script_name} v{__version__} ---") + print(f"Targeting Group: {created_group}\n") + + # 3. Check for existing directory target_dir = Path(created_group) if target_dir.exists() and not args.force: print(f"Error: Directory '{created_group}' already exists.") print("Use --force or -f to recreate the files.") sys.exit(1) - # 3. Setup template path + # 4. Setup template path template_dir = Path("TEMPLATE") if not template_dir.exists(): print(f"Error: {template_dir} directory not found.") @@ -46,20 +54,19 @@ def create_sc_group(): target_dir.mkdir(parents=True, exist_ok=True) - # 4. Initialize Jinja2 Environment + # 5. Initialize Jinja2 Environment env = Environment(loader=FileSystemLoader(str(template_dir))) - # 5. Context variables + # 6. Context variables (Description exposed here) render_vars = { "business_label": args.business_label, "application_label": args.application_label, "group": group_name, - "created_group": created_group + "created_group": created_group, + "description": args.description or "" } - print(f"{'Recreating' if args.force and target_dir.exists() else 'Creating'} files for: {created_group}") - - # 6. Process files + # 7. Process files for item in template_dir.iterdir(): if item.is_dir(): continue @@ -82,3 +89,4 @@ def create_sc_group(): if __name__ == "__main__": create_sc_group() +