Changed old argument parser to more sensible case statement; began work to recognize
any path as a valid note path.
This commit is contained in:
@@ -1,27 +1,49 @@
|
||||
#==============================================================================
|
||||
# Stage 2: Argument Parsing
|
||||
#==============================================================================
|
||||
NAME=""
|
||||
NOTEBOOK=""
|
||||
SECTION=""
|
||||
NOTE=""
|
||||
if [ -z "$1" ]; then help; exit 20
|
||||
else
|
||||
ARGS=( "$@" )
|
||||
for ARG in "${ARGS[@]}"; do
|
||||
if [ "$ARG" = "-c" ] || [ "$ARG" = "--create" ]; then CREATE="TRUE"; OP="TRUE"
|
||||
elif [ "$ARG" = "-d" ] || [ "$ARG" = "--delete" ]; then DELETE="TRUE"; OP="TRUE"
|
||||
elif [ "$ARG" = "-e" ] || [ "$ARG" = "--edit" ]; then EDIT="TRUE"; OP="TRUE"
|
||||
elif [ "$ARG" = "-ce" ] || [ "$ARG" = "-ec" ]; then EDIT="TRUE"; CREATE="TRUE"; OP="TRUE"
|
||||
elif [ "$ARG" = "-p" ] || [ "$ARG" = "--print" ]; then PRINT="TRUE"; OP="TRUE"
|
||||
elif [ "$ARG" = "-l" ] || [ "$ARG" = "--list" ]; then LIST="TRUE"; OP="TRUE"
|
||||
elif [ "$ARG" = "-h" ] || [ "$ARG" == "--help" ]; then help; exit 0
|
||||
elif [ "$ARG" = "-i" ] || [ "$ARG" == "--init" ]; then init_store; exit 0
|
||||
else
|
||||
if [ -z "$NAME" ] && [ -n "$ARG" ]; then NAME="$ARG"
|
||||
elif [ -z "$NOTEBOOK" ] && [ -n "$ARG" ]; then NOTEBOOK="$ARG"
|
||||
elif [ -z "$SECTION" ] && [ -n "$ARG" ]; then SECTION="$ARG"
|
||||
fi
|
||||
fi
|
||||
for ARG in "$@"; do
|
||||
case "$ARG" in
|
||||
-c|--create)
|
||||
CREATE="TRUE"
|
||||
OP="TRUE"
|
||||
;;
|
||||
-d|--delete)
|
||||
DELETE="TRUE"
|
||||
OP="TRUE"
|
||||
;;
|
||||
-e|--edit)
|
||||
EDIT="TRUE"
|
||||
OP="TRUE"
|
||||
;;
|
||||
-ce|-ec)
|
||||
CREATE="TRUE"
|
||||
EDIT="TRUE"
|
||||
OP="TRUE"
|
||||
;;
|
||||
-l|--list)
|
||||
LIST="TRUE"
|
||||
OP="TRUE"
|
||||
;;
|
||||
-p|--print)
|
||||
PRINT="TRUE"
|
||||
OP="TRUE"
|
||||
;;
|
||||
-h|--help)
|
||||
help
|
||||
exit 0
|
||||
;;
|
||||
-i|--init-store)
|
||||
init_store
|
||||
exit 0
|
||||
;;
|
||||
*)
|
||||
NOTE="$ARG"
|
||||
break;
|
||||
;;
|
||||
esac
|
||||
done
|
||||
if [ -n "$NAME" ] && [ -z "$NOTEBOOK" ] && [ -n "$LIST" ]; then
|
||||
# If a note title was specified, but no notebook, and the list option
|
||||
|
||||
Reference in New Issue
Block a user