-
-
Save weisk/5a4a2fff9df24dced7232e3a0399b6ea to your computer and use it in GitHub Desktop.
Bash script skeleton
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
#!/bin/bash | |
settings() { | |
SCRIPT_DIR="$(dirname "$0")" | |
} | |
main() { | |
request $@ | |
settings | |
run | |
} | |
run() { | |
echo "Do something" | |
} | |
syntax() { | |
echo "" | |
echo "Command description" | |
echo "" | |
echo "Usage:" | |
echo " command [options] [arguments]" | |
echo "" | |
echo "Options:" | |
echo " -h, --help Display this help message" | |
} | |
request() { | |
local SYNTAX=0 | |
while [[ $# > 1 ]] | |
do | |
case "$1" in | |
--help|-h) | |
SYNTAX=1 | |
;; | |
esac | |
shift | |
done | |
if [[ $SYNTAX -eq 1 ]]; then | |
syntax && die | |
fi | |
} | |
die() { | |
builtin echo $@ | |
exit 1 | |
} | |
main $@ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment