From b22930af771fe0fc12f302b58ed65607ae79b816 Mon Sep 17 00:00:00 2001 From: Alex Date: Mon, 8 Jul 2024 08:30:00 +0200 Subject: [PATCH] feat(aidd-pull-request.sh): add argument parsing and validation for template file path --- scripts/aiddc/scripts/aidd-pull-request.sh | 24 +++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/scripts/aiddc/scripts/aidd-pull-request.sh b/scripts/aiddc/scripts/aidd-pull-request.sh index 2743e30..54cd815 100644 --- a/scripts/aiddc/scripts/aidd-pull-request.sh +++ b/scripts/aiddc/scripts/aidd-pull-request.sh @@ -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