error checking

This commit is contained in:
Eric Lay 2023-04-29 22:24:52 -05:00
parent 607195c779
commit 3f8247eb6a
1 changed files with 31 additions and 12 deletions

View File

@ -37,6 +37,9 @@ mapfile -t ABILITIES < <(jq -r '.abilities[].ability | [.name, .url] | @tsv' <<<
mapfile -t LOCATE < <(jq -r '.[].location_area["name"]' <<< "$endpoint_ENCOUNTER")
### Print formatted data
## - a lot if/then to test for empty vars not found in API data
## - would like to catch this in jq step and avert any on screen errors
{ printf "\n %s %s Type Pokémon\n" \
"${NAME^}" "${TYPE_ITEM^}";
printf "\n %s\n" "$FLAVOR";
@ -79,14 +82,27 @@ printf " ↞--------| STATS |--------↠ \n";
for ((i=0; i<${#STAT[@]}; i++)); do
printf " %15s: %10s\n" "${STAT[i]}" "${VAL[i]}";
done;
if [[ -n "$GENUS" ]]
then
printf "\n Genus: %s" "${GENUS^}";
else
:
fi;
if [[ -n "$BASEX" ]] && [[ -n "$CAPTURE" ]]
then
printf "\n Happiness: %s\tPokedex ID: %s\n Base Exp: %s\tCapture Rate: %s\n Height: %s\tWeight: %s\n" \
"$BASEHAPPY" "$ID" "$BASEX" "$CAPTURE" "$HEIGHT" "$WEIGHT";
else
printf "\n Happiness: %s\tPokedex ID: %s\n Height: %s\tWeight: %s\n" \
"$BASEHAPPY" "$ID" "$HEIGHT" "$WEIGHT";
fi
printf "\n Types:\n"
for ((i=0; i<${#TYPE[@]}; i++)); do
TYPE_LIST_ITEM="${TYPE[i]}"
printf " %s\n" "${TYPE_LIST_ITEM^}"
done;
if [[ -n "$ABILITIES" ]]
then
printf "\n%s\n\n" " ↞---------------|ABILITIES|---------------↠"
for ((i=0; i<${#ABILITIES[@]}; i++)); do
ABILITY_NAME="$(awk '{print $1}' <<< "${ABILITIES[i]}")"
@ -96,6 +112,9 @@ for ((i=0; i<${#ABILITIES[@]}; i++)); do
printf " %s:\n\n" "${ABILITY_NAME^}"
printf " %s\n\n" "$EFFECT_ENTRY"
done;
else
:
fi
if [[ -n "$LOCATE" ]]
then
printf "\n Location Areas:\n";