From 595ba75f18e9dfc758608bc08f7de9ec65533a03 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Sat, 6 Jun 2015 16:26:49 -0600 Subject: toru: Clean up the option parser and usage text --- src/toru/toru | 46 +++++++++++++++++----------------------------- 1 file changed, 17 insertions(+), 29 deletions(-) diff --git a/src/toru/toru b/src/toru/toru index f714fd8..34a7649 100755 --- a/src/toru/toru +++ b/src/toru/toru @@ -249,11 +249,6 @@ update() { done # end repos } -# Find all the packages that are missing from the repo dbs (aka not built) -missing() { - true -} - ## Finds a PKGBUILD on toru's path cache ## usage: where_is # Look in all caches but pick the first one @@ -272,21 +267,16 @@ where_is() { echo ${_path} } -# TODO: clean usage instructions -function usage { - echo "" - echo "$0 [options] repo1 ... repon" - echo "" - echo "Make a db containing PKGBUILD metadata." - echo "" - echo "-h : this message" - # echo "-a : update all repos at once" - echo "-u : update repo information" - echo "-q : quiet" - echo "-f : rebuild the db even if it is updated" - echo "-p : return the path for pkgname" - echo "" - exit 1 +usage() { + print 'Usage: %s [OPTIONS] REPO1...REPON' "${0##*/}" + print "Make a db containing PKGBUILD metadata." + echo + #flag '-a' "Update all repos at once" \ + flag '-f' "Rebuild the db even if it is updated" \ + "-p <$(_ PKGNAME)>" "Return the path for PKGNAME" \ + '-q' "Quiet" \ + '-u' "Update repo information" \ + '-h' "Show this message" } ## MAIN @@ -294,22 +284,20 @@ commands=() repos=() quiet=false force=false -while getopts 'haqfpum' arg; do +while getopts 'fp:quh' arg; do case $arg in - h) usage; exit 0 ;; - # TODO: Update all repos on $REPOS array - # a) update_all_repos ;; - q) quiet=true ;; + #a) update_all_repos ;; # TODO: Update all repos on $REPOS array f) force=true ;; + p) where_is "$OPTARG" || exit 1 ;; + q) quiet=true ;; u) commands+=(update);; - p) shift $(( OPTIND - 1 )) - where_is "$1" || exit 1;; - m) commands+=(missing);; + h) usage; exit 0 ;; + ?) usage 1>&2; exit 1 ;; esac shift $(( OPTIND - 1 )) done - +[[ ${#commands[@]} -eq 0 ]] && { usage 1>&2; exit 1 ;; TMPDIR=$(mktemp -d) -- cgit v1.2.2