From 8379ac706a7c7a85fa0fbb122ae719246ab042d2 Mon Sep 17 00:00:00 2001 From: Eric Lay Date: Sat, 22 Apr 2023 15:56:33 -0500 Subject: [PATCH] arg parsing loop WIP --- pokedex-dev | 53 ++++++++++++++++++++++++++++++----------------------- 1 file changed, 30 insertions(+), 23 deletions(-) diff --git a/pokedex-dev b/pokedex-dev index 4190fbb..b6ff8de 100755 --- a/pokedex-dev +++ b/pokedex-dev @@ -1,6 +1,7 @@ #!/bin/bash ### Overhad preparation +shopt -s extglob KBINDS="/usr/share/fuzzy-pokedex-dev/keybindings-preview" POKEDATA="/usr/share/fuzzy-pokedex-dev/pokeData" @@ -61,27 +62,33 @@ update_pokeData() { pokemon-colorscripts -l | sort | parallel --progress --bar --color --retry-failed -j "${1:-200%}" pokeInfo {} ">" "$POKEDATA/{}" 2>&1 } -### Arg parsing loop -if [[ ! "$1" =~ ^- ]]; then - pokedex "$1" -else - while (( $# )); do - arg=$1 - shift - case "$arg" in - -q|--quick) - quick_view "$1" - ;; - -u|--update) - update_pokeData "$1" - ;; - -h|--help) - help - ;; - -*) - echo "Invalid Usage" - help - ;; - esac - done +if ! (( $# )); then + pokedex fi + +while (( $# )); do + arg=$1 + shift + case "$arg" in + -q|--quick) + quick_view "$1" + shift + ;; + -u|--update) + update_pokeData "$1" + shift + ;; + -h|--help) + help + shift + ;; + !(^-) ) + pokedex "$arg" + shift + ;; + -* ) + echo "Invalid Usage" + help + ;; + esac +done