Skip to content

Commit

Permalink
add --description
Browse files Browse the repository at this point in the history
  • Loading branch information
badra001 committed Jan 16, 2026
1 parent d8432dd commit f0a132b
Showing 1 changed file with 17 additions and 9 deletions.
26 changes: 17 additions & 9 deletions local-app/python-tools/sso-tools/sso-create-sc-group.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import argparse
import shutil
import sys
import os
from pathlib import Path
from jinja2 import Environment, FileSystemLoader

Expand All @@ -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__}")

Expand All @@ -31,35 +34,39 @@ 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.")
sys.exit(1)

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
Expand All @@ -82,3 +89,4 @@ def create_sc_group():

if __name__ == "__main__":
create_sc_group()

0 comments on commit f0a132b

Please sign in to comment.