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
|
# Stage 2: Argument Parsing
|
||||||
#==============================================================================
|
#==============================================================================
|
||||||
NAME=""
|
NOTE=""
|
||||||
NOTEBOOK=""
|
|
||||||
SECTION=""
|
|
||||||
if [ -z "$1" ]; then help; exit 20
|
if [ -z "$1" ]; then help; exit 20
|
||||||
else
|
else
|
||||||
ARGS=( "$@" )
|
for ARG in "$@"; do
|
||||||
for ARG in "${ARGS[@]}"; do
|
case "$ARG" in
|
||||||
if [ "$ARG" = "-c" ] || [ "$ARG" = "--create" ]; then CREATE="TRUE"; OP="TRUE"
|
-c|--create)
|
||||||
elif [ "$ARG" = "-d" ] || [ "$ARG" = "--delete" ]; then DELETE="TRUE"; OP="TRUE"
|
CREATE="TRUE"
|
||||||
elif [ "$ARG" = "-e" ] || [ "$ARG" = "--edit" ]; then EDIT="TRUE"; OP="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"
|
-d|--delete)
|
||||||
elif [ "$ARG" = "-l" ] || [ "$ARG" = "--list" ]; then LIST="TRUE"; OP="TRUE"
|
DELETE="TRUE"
|
||||||
elif [ "$ARG" = "-h" ] || [ "$ARG" == "--help" ]; then help; exit 0
|
OP="TRUE"
|
||||||
elif [ "$ARG" = "-i" ] || [ "$ARG" == "--init" ]; then init_store; exit 0
|
;;
|
||||||
else
|
-e|--edit)
|
||||||
if [ -z "$NAME" ] && [ -n "$ARG" ]; then NAME="$ARG"
|
EDIT="TRUE"
|
||||||
elif [ -z "$NOTEBOOK" ] && [ -n "$ARG" ]; then NOTEBOOK="$ARG"
|
OP="TRUE"
|
||||||
elif [ -z "$SECTION" ] && [ -n "$ARG" ]; then SECTION="$ARG"
|
;;
|
||||||
fi
|
-ce|-ec)
|
||||||
fi
|
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
|
done
|
||||||
if [ -n "$NAME" ] && [ -z "$NOTEBOOK" ] && [ -n "$LIST" ]; then
|
if [ -n "$NAME" ] && [ -z "$NOTEBOOK" ] && [ -n "$LIST" ]; then
|
||||||
# If a note title was specified, but no notebook, and the list option
|
# If a note title was specified, but no notebook, and the list option
|
||||||
|
|||||||
Reference in New Issue
Block a user