From 87ca921b141c64b9ddf7fd597bc60aa866c5e24d Mon Sep 17 00:00:00 2001 From: Yasen Pramatarov Date: Mon, 3 Jun 2024 14:35:50 +0300 Subject: [PATCH] Fixes short and long commandline options. --- jilo-cli | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/jilo-cli b/jilo-cli index 2a4c011..fab3ab6 100755 --- a/jilo-cli +++ b/jilo-cli @@ -80,20 +80,29 @@ db_query() { fi } -# commandline options +### commandline options -while getopts ":cpt" opt; do - case $opt in - c) +cmd="" + +while [[ $# -gt 0 ]]; do + case "$1" in + -c | --conferences ) cmd="--conferences" + shift ;; - p) + -p | --participants) cmd="--participants" + shift ;; - t) + -t | --time) cmd="--time" + sift ;; - \?) + -h | --help) + echo -e "$help" + exit 0 + ;; + *) echo "Invalid option: -$OPTARG" >&2 echo -e "$help" exit 1 @@ -110,7 +119,7 @@ case "$cmd" in exit 0 ;; - --participant|--participants) + --participants) db_stats_participants=$(printf "$db_stats_participants_template" ) db_query "$db_stats_participants" exit 0