diff --git a/sit b/sit index 33b26e0..2c5e5e1 100755 --- a/sit +++ b/sit @@ -4,18 +4,19 @@ # # Copyright (c) 2011-2016 Christoph Niethammer # - -# exit on any error! -set -e -# for debugging: -# set -x +set -e SIT_PATH=$(cd $(dirname $PWD/$0); pwd) SIT_CONFIG_FILE=$SIT_PATH/etc/sit.conf SIT_USER_CONFIG_FILE=$HOME/.sit -function usage() { - echo "Usage: $0 [action] " +function show_help() { + echo "Usage: $0 [options] [action] " + echo "Options:" + echo " -h,--help" + echo " -v,--verbose" + echo " --debug" + echo echo "Valid actions:" echo " sitinfo" echo " unpack" @@ -31,35 +32,45 @@ function usage() { echo " all" } -# sit class file to be installed -sit_classfile="" -# sit action to be performed -sit_action="all" +verbose=0 +debug=0 +sit_classfile="" # sit class file to be installed +sit_action="all" # sit action to be performed while [ "$1" != "" ] ; do case $1 in - "sitinfo"| \ - "all"| \ - "unpack"| \ - "prepare"| \ - "configure"| \ - "build"| \ - "pretest"| \ - "install"| \ - "posttest"| \ - "postinst"| \ - "copy_logs"| \ - "setperms") - sit_action=$1 - ;; - "-*h"|"--help"|"help"|"usage") - usage $@ - exit 0 - ;; - *) - sit_classfile=$1 - ;; + -h|-\?|--help) + show_help + exit + ;; + --debug) + echo "Debug mode enabled" + set -x + debug=1 + ;; + -v|--verbose) + verbose=$((verbose + 1)) + ;; + + sitinfo| \ + all| \ + unpack| \ + prepare| \ + configure| \ + build| \ + pretest| \ + install| \ + posttest| \ + postinst| \ + copy_logs| \ + setperms) + sit_action=$1 + ;; + *) + sit_classfile=$1 + ;; esac + shift done