Merge pull request #78 from jumanjiman/usage

improve CLI option handling
This commit is contained in:
Thomas Sjögren 2015-09-05 15:33:56 +02:00
commit a010128ed2

View file

@ -35,11 +35,12 @@ if [ $? -ne 0 ]; then
fi fi
usage () { usage () {
printf " cat <<EOF
usage: %s [options] usage: ${myname} [options]
-h optional Print this help message\n" "$myname" -h optional Print this help message
exit 1 -l PATH optional Log output in PATH
EOF
} }
yell "# ------------------------------------------------------------------------------ yell "# ------------------------------------------------------------------------------
@ -62,12 +63,14 @@ if [ "x$ID" != "x0" ]; then
fi fi
# Get the flags # Get the flags
while getopts :hlfi: args # If you add an option here, please
# remember to update usage() above.
while getopts hl: args
do do
case $args in case $args in
h) usage ;; h) usage; exit 0 ;;
l) logger="$OPTARG" ;; l) logger="$OPTARG" ;;
*) usage ;; *) usage; exit 1 ;;
esac esac
done done