Created
December 13, 2019 16:29
-
-
Save jmackie/baf544598ff909fb4da6ba1da673bb72 to your computer and use it in GitHub Desktop.
Bash build script starter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# Enable bash "strict mode" | |
# http://redsymbol.net/articles/unofficial-bash-strict-mode/ | |
set -euo pipefail | |
IFS=$'\n\t' | |
# Some nice colour functions, you might want to add more... | |
# https://gist.github.com/daytonn/8677243 | |
blue="\033[0;34m" | |
end="\033[0m" | |
blue() { echo -e "${blue}${1}${end}"; } | |
# Usage documentation | |
USAGE=$(cat <<EOF | |
This is how to use this: | |
$(blue 'DOCUMENTATION HERE') | |
EOF | |
) | |
# No first argument | |
if [ -z ${1+x} ]; then | |
echo "$USAGE" | |
exit 1 | |
fi | |
# Actual scripts | |
build() { | |
echo Build script goes here... | |
exit 0 | |
} | |
case "$1" in | |
build) | |
build | |
;; | |
help|-h|--help) | |
echo "$USAGE" | |
exit 0 | |
;; | |
*) | |
echo "Bad usage" | |
echo | |
echo "$USAGE" | |
exit 1 | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment