Skip to content
This repository has been archived by the owner on Nov 28, 2023. It is now read-only.

Commit

Permalink
Fix cli parsing
Browse files Browse the repository at this point in the history
Always shift first argument when successfully parsing an argument.
Set APP_NAME to the correct value.

Use more flexible log level instead of separate flags.
Switch to case statements for more concise code.
  • Loading branch information
Michael Pitidis committed Jun 13, 2014
1 parent 859a87b commit 4881226
Showing 1 changed file with 10 additions and 22 deletions.
32 changes: 10 additions & 22 deletions jdump.sh
Expand Up @@ -28,35 +28,23 @@ Options:
"
}

APP_NAME="$1"

# check if things should be done quietly
QUIET=false
NO_WARN=false
if [ "$1" == "-q" ]
then
QUIET=true
shift
elif [ "$1" == "-qq" ]
then
QUIET=true
NO_WARN=true
fi
# set the appropriate log level
LEVEL=0
case "$1" in
-q) LEVEL=1; shift;;
-qq) LEVEL=2; shift;;
esac

function info() {
if [ $QUIET == false ]
then
echo -e $*
fi
[[ $LEVEL -lt 1 ]] && echo -e "$@"
}

function warn() {
if [ $NO_WARN == false ]
then
echo -e $* 1>&2
fi
[[ $LEVEL -lt 2 ]] && echo -e "$@" 1>&2
}

APP_NAME="$1"

function generate() {
PROG="$1"
ARGS="$2"
Expand Down

0 comments on commit 4881226

Please sign in to comment.