add standard --help/--version options
authorMike Frysinger <vapier@gentoo.org>
Sun, 7 Oct 2007 19:16:50 +0000 (19:16 -0000)
committerMike Frysinger <vapier@gentoo.org>
Sun, 7 Oct 2007 19:16:50 +0000 (19:16 -0000)
svn path=/main/trunk/; revision=7993

bin/etc-update

index d40400d192bee192191a4e18155fee4434873b8f..73dfb6bf051750e5e0eb84135037dbcfd1d2b099 100755 (executable)
@@ -445,10 +445,34 @@ die() {
        exit ${2}
 }
 
+usage() {
+       cat <<-EOF
+       etc-update: Handle configuration file updates
+
+       Usage: etc-update [options]
+
+       Options:
+         -h, --help     Show help and run away
+         -V, --version  Show version and trundle away
+       EOF
+
+       [[ -n ${*:2} ]] && printf "\nError: %s\n" "${*:2}" 1>&2
+
+       exit ${1:-0}
+}
+
 #
 # Run the script
 #
-scriptname=$(basename $0)
+
+while [[ -n $1 ]] ; do
+       case $1 in
+               -h|--help)    usage;;
+               -V|--version) echo '$Id$'; exit 0;;
+               *)            usage 1 "Invalid option '$1'";;
+       esac
+       shift
+done
 
 type portageq > /dev/null || exit $?
 eval $(portageq envvar -v CONFIG_PROTECT \