Last active
February 14, 2021 13:23
-
-
Save bashelled/00bfbe26eb666cde151ee9aa74411fea to your computer and use it in GitHub Desktop.
Script template for --help/-h and --version - clone manually, because formatting will give errors.
This file contains hidden or 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 | |
# a short template for --help and --version | |
# Script declaration | |
SCRIPTNAME="${0##*[\\/]}" | |
SCRIPTVERSION="1.0" | |
function apphelp # This will be shown when you run (name) --help. | |
{ | |
cat << EOF | |
Usage: $SCRIPTNAME | |
A description to your script can be listed here. | |
-h, --help display this help and exit | |
--version output version information and exit | |
EOF | |
} | |
if [[ "$1" == "-h" || "$1" == "--help" ]]; then | |
apphelp | |
elif [[ "$1" == "--version" ]]; then | |
echo "$SCRIPTNAME $SCRIPTVERSION" | |
elif [[ "$1" == "--m00h" ]]; then | |
echo "Have you mooed today?" | |
else | |
echo "Well, what do you want me to say? You haven't put any code!" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment