feat: retrieve next argument and assemble template

This commit is contained in:
Rejman Nascimento 2024-02-23 10:12:26 -03:00
commit 48b36d5bb2

View file

@ -35,26 +35,34 @@ remove_flags() {
}; };
build_message () { build_message () {
if [[ "$*" =~ (-sa|-as) ]]; then local argv=("$@")
local attention='!' local argc=${#@}
local scope="($2)" local i=0
elif [[ "$1" =~ (-a|--attention) ]]; then
local attention='!'
elif [[ "$2" =~ (-a|--attention) ]]; then
local attention='!'
elif [[ "$*" =~ (-a|--attention) ]]; then
local attention='!'
fi
if [[ "$*" =~ (-s|--scope) ]]; then while [ $i -lt $argc ];
local scope="($2)" do
elif [[ "$2" =~ (-s|--scope) ]]; then if [[ "${argv[$i]}" =~ (-sa|-as) ]]; then
local scope="($3)" local attention='!'
fi local scope="(${argv[$i + 1]})"
i=$[$i + 1]
fi
local message="'$type'${scope}$attention: $@"; if [[ "${argv[$i]}" =~ (-a|--attention) ]]; then
local attention='!'
i=$[$i + 1]
fi
git commit -m $(remove_flags "$message" "${_git_commit_flags[@]}") if [[ "${argv[$i]}" =~ (-s|--scope) ]]; then
local scope="(${argv[$i + 1]})"
i=$[$i + 1]
fi
i=$[$i + 1]
done
local template="'$type'${scope}$attention: ${@}";
local message=$(remove_flags "$template" "${_git_commit_flags[@]}")
git commit -m "$message"
}; };
local alias type local alias type