Fix subcommand -> function mapper
This commit is contained in:
		
							
								
								
									
										9
									
								
								abra
									
									
									
									
									
								
							
							
						
						
									
										9
									
								
								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`) | ||||
|  | ||||
		Reference in New Issue
	
	Block a user