From 58bfcae1f04442827dcca05614cf62f81a935474 Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Tue, 27 Mar 2012 21:28:18 +0000 Subject: add -h/--help options Signed-off-by: Mike Frysinger --- build-docbook-catalog | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/build-docbook-catalog b/build-docbook-catalog index c80796b..6e19ebf 100755 --- a/build-docbook-catalog +++ b/build-docbook-catalog @@ -1,5 +1,5 @@ #!/bin/bash -# $Header: /usr/local/src/gentoo/gentoo-src/cvsroot/gentoo-src/build-docbook-catalog/build-docbook-catalog,v 1.8 2012/03/27 21:23:00 vapier Exp $ +# $Header: /usr/local/src/gentoo/gentoo-src/cvsroot/gentoo-src/build-docbook-catalog/build-docbook-catalog,v 1.9 2012/03/27 21:28:18 vapier Exp $ # # build-docbook-catalog: populate /etc/xml/docbook based in # installed docbook-xml-dtd versions. @@ -18,20 +18,37 @@ LATEST_DATE= VERBOSE=false ZERO=${0##*/} +# +# usage! +# +usage() { + cat <<-EOF + Usage: ${ZERO} [options] + + Options: + -v, --verbose Be verbose + -h, --help This! + EOF + [[ $# -gt 0 ]] && eerror "$*" + exit 0 +} + # # main (called from bottom) # main() { typeset d v opts - opts=$(getopt -o v --long verbose -n "$ZERO" -- "$@") || exit 1 + opts=$(getopt -o hv --long help,verbose -n "$ZERO" -- "$@") || exit 1 eval set -- "$opts" while true; do case "$1" in - -v|--verbose) VERBOSE=true ; shift ;; - --) shift ; break ;; - *) error "options parsing failed on $1!" ;; + -h|--help) usage ;; + -v|--verbose) VERBOSE=true ;; + --) break ;; + *) usage "options parsing failed on $1!" ;; esac + shift done create_catalogs # will exit on error -- cgit v1.2.3-65-gdbad