From bb35a97da470cb2ed0487da0bad53c759ee5c03b Mon Sep 17 00:00:00 2001 From: brettlangdon Date: Tue, 19 Jan 2016 19:10:46 -0500 Subject: [PATCH] cleanup usage and command/option parsing --- bin/git-vendor | 38 +++++++++++++++----------------------- 1 file changed, 15 insertions(+), 23 deletions(-) diff --git a/bin/git-vendor b/bin/git-vendor index ba4707a..00df77a 100755 --- a/bin/git-vendor +++ b/bin/git-vendor @@ -4,38 +4,30 @@ # # Copyright (c) 2016 Brett Langdon # -if [ $# -eq 0 ]; -then - set -- -h -fi - -OPTS_SPEC="\ -git vendor add -git vendor list -git vendor update --- -" -eval "$(echo "$OPTS_SPEC" | git rev-parse --parseopt -- "$@" || echo exit $?)" +_usage() +{ + cat < + git vendor list + git vendor update +EOF +} PATH=$PATH:$(git --exec-path) . git-sh-setup - require_work_tree -while [ $# -gt 0 ]; do - opt="$1" - shift - case "$opt" in - --) break ;; - *) die "Unexpected option: $opt" ;; - esac -done +case "$1" in + ""|"--help") _usage && exit ;; +esac command="$1" shift case "$command" in - add|list|update) ;; - *) die "Unknown command '$command'" ;; + "add"|"list"|"update") ;; + *) >&2 echo "error: unknown command \"$command\"" && _usage && exit 1 ;; esac vendor_dirs_from_log()