From 0433da368994d7fa9c473f04c7bce8006b3c588e Mon Sep 17 00:00:00 2001 From: 3wc <3wc.git@doesthisthing.work> Date: Fri, 30 Oct 2020 18:17:06 +0200 Subject: [PATCH] Fix subcommand -> function mapper --- abra | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/abra b/abra index e701597..b43bf4b 100755 --- a/abra +++ b/abra @@ -874,24 +874,19 @@ abra() { load_custom_commands - # Note(decentral1se): experimenting with subcmd parsing - if [ ${abra_app} ] && [ ${abra_secret} ] && [ ${abra_rm} ]; then - sub_app_secret_delete ${abra__args_[*]} - return - fi - # Search for sub_* functions, and check if any of them matches enabled # arguments (i.e. is a command and is specified) for SUBCOMMAND in $(declare -Ff | grep 'sub_' | cut -d' ' -f3 | sort -r); do IFS='_' read -r -a PARTS <<< "$SUBCOMMAND" for PART in "${PARTS[@]:1}"; do - # TODO 3wc: probably a better way to check if a function is defined.. + # TODO 3wc: probably a better way to check if a variable is defined.. VAR=$(eval "echo \$abra_$PART") if [ ! "$VAR" == "true" ]; then continue 2 fi done abra__command_=$(IFS="_"; echo "${PARTS[*]:1}") + break done # Use abra__command_ in case `command` is provided (i.e. `volume` or `stack`)