From be8ed0045aa82cac5e5d8c004d281dad93046d68 Mon Sep 17 00:00:00 2001 From: Donald Ephraim Curtis Date: Fri, 20 Jan 2012 20:40:29 -0600 Subject: [PATCH] Better option handling. --- melpa | 39 ++++++++++++++++++++++++++++++++++----- 1 file changed, 34 insertions(+), 5 deletions(-) diff --git a/melpa b/melpa index 9aeefe5c..e315ca73 100755 --- a/melpa +++ b/melpa @@ -53,14 +53,39 @@ else print}' index.tmpl > index.md echo } -args=$@ +function print_usage { + echo "usage: $0 [-h | -?] [update | clear | build | html | sync]" +} -if [[ "$#" == "0" ]]; then - args="update clear build index sync" +args=`getopt h $*` +errcode=$? + +if [[ "$errcode" > 0 ]]; then + print_usage + exit $errcode fi -for task in $args; do - case $task in +set -- $args + +for i; do + case "$i" in + -h | -?) print_usage + shift + exit + ;; + --) shift + break + ;; + esac +done + + +if [[ "$#" == "0" ]]; then + set -- update clear build index sync +fi + +for i; do + case $i in update ) melpa_update_epkgs ;; clear ) melpa_clear_packages ;; build ) melpa_build_pkglist ;; @@ -70,4 +95,8 @@ for task in $args; do shift done +exit 1 + + +