From a71471fc408e1de682eb9f0517f3dbc4231a6fba Mon Sep 17 00:00:00 2001 From: southerntofu Date: Tue, 1 Dec 2020 15:35:22 +0100 Subject: [PATCH] Provide version information in help and --version|-V flag --- forgebuild.sh | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/forgebuild.sh b/forgebuild.sh index 21f8bb7..8a887da 100755 --- a/forgebuild.sh +++ b/forgebuild.sh @@ -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