Skip to content

Instantly share code, notes, and snippets.

@dekarrin
Last active April 29, 2021 19:14
Show Gist options
  • Save dekarrin/d0ce500bec820d340458a0bf32b15a49 to your computer and use it in GitHub Desktop.
Save dekarrin/d0ce500bec820d340458a0bf32b15a49 to your computer and use it in GitHub Desktop.
# parse args
PARAMS=""
while (( "$#" )); do
case "$1" in
-t|--telegraf-conf-dir)
telegraf_conf_install_dir="$2"
shift 2
;;
-h|--help)
echo "usage: $0 [<flags>]"
echo "Installs app onto a centos system"
echo ""
echo "Flags:"
echo ' -h, --help Show this help and exit'
echo ' -t, --telegraf-conf-dir "path" Set install directory of telegraf config. Default is /etc/telegraf/telegraf.d'
echo ' -- Flag end marker; no flags after this will be parsed'
exit 0
;;
--) # end argument parsing
shift
break
;;
-*|--*=) # unsupported flags
echo "Error: Unsupported flag $1" >&2
echo "Invoke with -h or --help for help" >&2
exit 1
;;
*) # preserve positional arguments
PARAMS="$PARAMS $1"
shift
;;
esac
done
# set positional arguments in their proper place
eval set -- "$PARAMS"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment