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