Changed argument parser to getopts
This commit is contained in:
@@ -98,14 +98,14 @@ NOTE=""
|
||||
if [ -z "$1" ]; then help; exit 20
|
||||
else
|
||||
INDEX=0
|
||||
for ARG in "$@"; do
|
||||
while getopts ":cCd:xe:xl:xp:xhi" ARG $VCTL; do
|
||||
let INDEX++
|
||||
case "$ARG" in
|
||||
-c|--create)
|
||||
c|--create)
|
||||
CREATE="TRUE"
|
||||
OP="TRUE"
|
||||
;;
|
||||
-C|--config)
|
||||
C|--config)
|
||||
if [ -z "$EDITOR" ]; then
|
||||
printf "$YELLOW_COLOR!$RESET_COLOR - %s\n"\
|
||||
"No editor defined. Defaulting to vi."
|
||||
@@ -114,32 +114,27 @@ else
|
||||
"$EDITOR" "$CONFIG_FILE"
|
||||
exit 0;
|
||||
;;
|
||||
-d|--delete)
|
||||
d|--delete)
|
||||
DELETE="TRUE"
|
||||
OP="TRUE"
|
||||
;;
|
||||
-e|--edit)
|
||||
e|--edit)
|
||||
EDIT="TRUE"
|
||||
OP="TRUE"
|
||||
;;
|
||||
-ce|-ec)
|
||||
CREATE="TRUE"
|
||||
EDIT="TRUE"
|
||||
OP="TRUE"
|
||||
;;
|
||||
-l|--list)
|
||||
l|--list)
|
||||
LIST="TRUE"
|
||||
OP="TRUE"
|
||||
;;
|
||||
-p|--print)
|
||||
p|--print)
|
||||
PRINT="TRUE"
|
||||
OP="TRUE"
|
||||
;;
|
||||
-h|--help)
|
||||
h|--help)
|
||||
help
|
||||
exit 0
|
||||
;;
|
||||
-i|--init-store)
|
||||
i|--init-store)
|
||||
init_store
|
||||
exit 0
|
||||
;;
|
||||
|
||||
Reference in New Issue
Block a user