fix(args): allow setting the output via --output argument

This commit is contained in:
Orhun Parmaksız
2025-07-13 20:46:23 +03:00
parent 104a6cf3c9
commit d59ebfc46f

22
run.sh
View File

@@ -21,8 +21,26 @@ chown -R "$(id -u)" .
OUTPUT=${OUTPUT:="git-cliff/CHANGELOG.md"} OUTPUT=${OUTPUT:="git-cliff/CHANGELOG.md"}
mkdir -p "$(dirname $OUTPUT)" mkdir -p "$(dirname $OUTPUT)"
# Separate arguments before passing them to git-cliff command args=()
args=$(echo "$@" | xargs) take_next=
for arg in "$@"; do
case "$arg" in
-o | --output)
take_next=1 # next argument is the output file
;;
-o=* | --output=*)
OUTPUT="${arg#*=}" # consume the output file directly
;;
*)
if [ -n "$take_next" ]; then
OUTPUT="$arg"
take_next=
else
args+=("$arg") # keep only non-output args
fi
;;
esac
done
# Execute git-cliff # Execute git-cliff
GIT_CLIFF_OUTPUT="$OUTPUT" "$GIT_CLIFF_PATH" $args GIT_CLIFF_OUTPUT="$OUTPUT" "$GIT_CLIFF_PATH" $args