Fixes short and long commandline options.

main
Yasen Pramatarov 2024-06-03 14:35:50 +03:00
parent 6e6baea905
commit 87ca921b14
1 changed files with 17 additions and 8 deletions

View File

@ -80,20 +80,29 @@ db_query() {
fi fi
} }
# commandline options ### commandline options
while getopts ":cpt" opt; do cmd=""
case $opt in
c) while [[ $# -gt 0 ]]; do
case "$1" in
-c | --conferences )
cmd="--conferences" cmd="--conferences"
shift
;; ;;
p) -p | --participants)
cmd="--participants" cmd="--participants"
shift
;; ;;
t) -t | --time)
cmd="--time" cmd="--time"
sift
;; ;;
\?) -h | --help)
echo -e "$help"
exit 0
;;
*)
echo "Invalid option: -$OPTARG" >&2 echo "Invalid option: -$OPTARG" >&2
echo -e "$help" echo -e "$help"
exit 1 exit 1
@ -110,7 +119,7 @@ case "$cmd" in
exit 0 exit 0
;; ;;
--participant|--participants) --participants)
db_stats_participants=$(printf "$db_stats_participants_template" ) db_stats_participants=$(printf "$db_stats_participants_template" )
db_query "$db_stats_participants" db_query "$db_stats_participants"
exit 0 exit 0