Skip to content

Commit

Permalink
feat(aidd-pull-request.sh): add argument parsing and validation for t…
Browse files Browse the repository at this point in the history
…emplate file path
  • Loading branch information
alexsoyes committed Jul 16, 2024
1 parent f85ef16 commit b22930a
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion scripts/aiddc/scripts/aidd-pull-request.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,32 @@ check_binary "git"
# NOTICE
# --------------------
notice "[aiddc-pull-request]: Preparing pull request with pre-filled Template"
echo "Args:
- 1: Template file path (default: $DEFAULT_PARAM)
Example:
$ aiddc-pull-request './my-projects/.github/pull_request_template.md'
"

# SCRIPT PARAMS
# --------------------
DEFAULT_PARAM="$(dirname "$0")/../templates/pull_request_template.md"
PARAM=${1:-$DEFAULT_PARAM}

# Validate the parameter
if [ "$PARAM" = "$DEFAULT_PARAM" ]; then
notice "[aiddc-pull-request]: Using default template"
fi

if [ ! -f "$PARAM" ]; then
error "Template file does not exist: $PARAM"
exit 1
fi

# PARAMETERS
# --------------------
TEMPLATE=$(cat templates/pull_request_template.md)
TEMPLATE=$PARAM
CHANGES=$(git diff main)

# PROMPT
Expand Down

0 comments on commit b22930a

Please sign in to comment.