Files
vns/init/stage2.sns.sh
Jon-William Lewis 64e504ebcb v2.0a3 -> v2.0a4
Rearranged tree to be more sane.
Made formatting changes to stage 2.
Fixed a bug where edit would be bypassed if the note was just created.
2015-05-07 21:23:12 -05:00

45 lines
1.7 KiB
Bash

#==============================================================================
# Section: Argument Parsing
#==============================================================================
NAME=""
NOTEBOOK=""
SECTION=""
if [ -z "$1" ]; then #If no input was given, print help
help
exit 20
else #Assume the user wants to do something.
ARGS=( "$@" )
for ARG in ${ARGS[@]};do
if [ "$ARG" = "-c" -o "$ARG" = "--create" ]; then CREATE="TRUE"
elif [ "$ARG" = "-d" -o "$ARG" = "--delete" ]; then DELETE="TRUE"
elif [ "$ARG" = "-e" -o "$ARG" = "--edit" ]; then EDIT="TRUE"
elif [ "$ARG" = "-ce" -o "$ARG" = "-ec" ]; then EDIT="TRUE";CREATE="TRUE"
elif [ "$ARG" = "-p" -o "$ARG" = "--print" ]; then PRINT="TRUE"
elif [ "$ARG" = "-l" -o "$ARG" = "--list" ]; then LIST="TRUE"
elif [ "$ARG" = "-h" -o "$ARG" == "--help" ]; then help; exit 0
elif [ "$ARG" = "-w" -o "$ARG" == "--wconf" ]; then w_conf; exit
else
if [ -z "$NAME" -a -n $ARG ]; then
NAME=$ARG
elif [ -z "$NOTEBOOK" -a -n $ARG ]; then
NOTEBOOK=$ARG
elif [ -z "$SECTION" -a -n $ARG ]; then
SECTION=$ARG
fi
fi
done
if [ -n "$NAME" -a -z "$NOTEBOOK" ]; then
NOTEBOOK="$NAME"
NAME=""
fi
fi
# Note: w_conf has highest priority, and it is the only function that can
# work without any parameters.
#==============================================================================
# End Section: Argument Parsing
#==============================================================================