Skip to content

Commit

Permalink
Update scaf and add template options
Browse files Browse the repository at this point in the history
  • Loading branch information
rehan892 committed Jan 15, 2025
1 parent 6c68472 commit b7233de
Showing 1 changed file with 23 additions and 5 deletions.
28 changes: 23 additions & 5 deletions scaf
Original file line number Diff line number Diff line change
@@ -13,9 +13,6 @@ fi
# Scaf challenge script
CHALLENGE_CONFIG_PATH=".scaf-challenge.json"

# Default repository URL if none is provided
DEFAULT_REPO_URL="https://github.com/sixfeetup/scaf-templates.git"

# Ensure at least one argument is provided (for project_slug)
if [ $# -lt 1 ]; then
echo "Usage: $0 project_slug [OPTIONS] [TEMPLATE]"
@@ -37,21 +34,42 @@ CLUSTER_SLUG=${PROJECT_SLUG//_/-}
COOKIECUTTER_SLUG=${PROJECT_SLUG//-/_}

# Assume the last argument is the template URL unless it starts with a dash
REPO_URL=""
if [ $# -gt 0 ]; then
LAST_ARG="${@: -1}"
if [[ $LAST_ARG == -* ]]; then
REPO_URL="$DEFAULT_REPO_URL"
COOKIECUTTER_OPTIONS="$@"
else
REPO_URL="$LAST_ARG"
# Remove the last argument (the REPO_URL) from the options
COOKIECUTTER_OPTIONS="${@:1:$(($#-1))}"
fi
else
REPO_URL="$DEFAULT_REPO_URL"
COOKIECUTTER_OPTIONS=""
fi

# If no repo URL was provided, ask for template selection
if [ -z "$REPO_URL" ]; then
echo "Please choose a template:"
echo "1) SFU Full Stack Template"
echo "2) AWS CLI Template"
echo -n "Enter the number corresponding to your choice (1 or 2): "
read -r template_choice

case $template_choice in
1)
REPO_URL="https://github.com/sixfeetup/scaf-fullstack-temlate.git"
;;
2)
REPO_URL="https://github.com/sixfeetup/scaf-aws-lambda-app-template.git"
;;
*)
echo "Invalid choice. Using default SFU Full Stack Template."
REPO_URL="https://github.com/sixfeetup/scaf-aws-lambda-app-template.git"
;;
esac
fi

# Check if --challenge is in scaf cli arguments
SCAF_CHALLENGE="n"
if [[ $COOKIECUTTER_OPTIONS == *"--challenge"* ]]; then

0 comments on commit b7233de

Please # to comment.