Fix subcommand -> function mapper
This commit is contained in:
parent
3e0b9e9475
commit
0433da3689
9
abra
9
abra
@ -874,24 +874,19 @@ abra() {
|
|||||||
|
|
||||||
load_custom_commands
|
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
|
# Search for sub_* functions, and check if any of them matches enabled
|
||||||
# arguments (i.e. is a command and is specified)
|
# arguments (i.e. is a command and is specified)
|
||||||
for SUBCOMMAND in $(declare -Ff | grep 'sub_' | cut -d' ' -f3 | sort -r); do
|
for SUBCOMMAND in $(declare -Ff | grep 'sub_' | cut -d' ' -f3 | sort -r); do
|
||||||
IFS='_' read -r -a PARTS <<< "$SUBCOMMAND"
|
IFS='_' read -r -a PARTS <<< "$SUBCOMMAND"
|
||||||
for PART in "${PARTS[@]:1}"; do
|
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")
|
VAR=$(eval "echo \$abra_$PART")
|
||||||
if [ ! "$VAR" == "true" ]; then
|
if [ ! "$VAR" == "true" ]; then
|
||||||
continue 2
|
continue 2
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
abra__command_=$(IFS="_"; echo "${PARTS[*]:1}")
|
abra__command_=$(IFS="_"; echo "${PARTS[*]:1}")
|
||||||
|
break
|
||||||
done
|
done
|
||||||
|
|
||||||
# Use abra__command_ in case `command` is provided (i.e. `volume` or `stack`)
|
# Use abra__command_ in case `command` is provided (i.e. `volume` or `stack`)
|
||||||
|
Reference in New Issue
Block a user