Better option handling.

This commit is contained in:
Donald Ephraim Curtis 2012-01-20 20:40:29 -06:00
parent fb5aa7ea50
commit be8ed0045a

39
melpa
View file

@ -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