Provide version information in help and --version|-V flag

This commit is contained in:
southerntofu 2020-12-01 15:35:22 +01:00
parent 9b4db4a174
commit a71471fc40
1 changed files with 12 additions and 2 deletions

View File

@ -1,5 +1,7 @@
#! /bin/bash
VERSION="0.4.0"
# Catch signals so we don't leave zombie tasks behind if we Ctrl^C
# No idea why but it seems to prevent the script from working? Disable!
#trap "exit" INT TERM ERR
@ -77,12 +79,17 @@ debug () {
[[ $COLORS = 1 ]] && echo -e "\e[36m$(trans debug)\e[0m$(trans $1)" | envsubst > /dev/stderr || echo "$(trans debug)$(trans $1)" | envsubst > /dev/stderr
}
version() {
echo "forgebuild $VERSION"
}
help () {
echo "forgebuild [tasks]"
version
echo "Usage: forgebuild [tasks]"
echo " Trigger updates on \`tasks\` (all tasks by default)"
echo "ARGS:"
echo " -f: force run of tasks regardless of updates on the repository"
echo " -b BASEDIR: consider tasks from BASEDIR, not ~/.forgebuild"
echo " -b BASEDIR: load tasks from BASEDIR (defaults to ~/.forgebuild)"
}
# DVCS stuff (for tasks with source)
@ -264,6 +271,9 @@ for arg in "$@"; do
elif [[ "$arg" = "-h" ]] || [[ "$arg" = "--help" ]]; then
help
exit 0
elif [[ "$arg" = "-V" ]] || [[ "$arg" = "--version" ]]; then
version
exit 0
elif [[ "$arg" = "-b" ]] || [[ "$arg" = "--basedir" ]]; then
FOUND_BASEDIR=1
elif [ -x $BASEDIR/$arg ]; then