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='!' while [ $i -lt $argc ];
elif [[ "$2" =~ (-a|--attention) ]]; then do
local attention='!' if [[ "${argv[$i]}" =~ (-sa|-as) ]]; then
elif [[ "$*" =~ (-a|--attention) ]]; then
local attention='!' local attention='!'
local scope="(${argv[$i + 1]})"
i=$[$i + 1]
fi fi
if [[ "$*" =~ (-s|--scope) ]]; then if [[ "${argv[$i]}" =~ (-a|--attention) ]]; then
local scope="($2)" local attention='!'
elif [[ "$2" =~ (-s|--scope) ]]; then i=$[$i + 1]
local scope="($3)"
fi fi
local message="'$type'${scope}$attention: $@"; if [[ "${argv[$i]}" =~ (-s|--scope) ]]; then
local scope="(${argv[$i + 1]})"
i=$[$i + 1]
fi
i=$[$i + 1]
done
git commit -m $(remove_flags "$message" "${_git_commit_flags[@]}") local template="'$type'${scope}$attention: ${@}";
local message=$(remove_flags "$template" "${_git_commit_flags[@]}")
git commit -m "$message"
}; };
local alias type local alias type