This commit is contained in:
Eric Lay 2023-04-20 21:24:05 -05:00
parent 56376b47bb
commit c7a8454b94
1 changed files with 17 additions and 19 deletions

36
pokedex
View File

@ -2,13 +2,10 @@
### Help ### Help
help() { help() {
echo -e "\nUse fzf to search Pokemon stats\n" printf "\n%s\n%s\n\n" "Use fzf to search Pokemon stats" "Can optionally search by name"
echo -e "Can optionally search by name" printf "%s\n\t%s\n\n%s" "EXAMPLE" "pokedex [pokemon name]"
echo -e "EXAMPLE\n\tpokedex [pokemon name]\n" printf "%s\n\t%s\n\t\t%s\n\t%s\n\t\t%s\n\t\t%s\n\t\t%s\n\t\t%s\n\t%s\n\t\t%s\n\n" "OPTIONS" "-q, --quick [pokemon]" "Prints single pokedex entry to terminal" "-u, --update [N/+N/-N/N%]" "Scrape web for updated Pokemon stats" "WARNING: update function is resource heavy" "See Parallel job control (-j) for options" "Default is 200%" "-h, --help" "Print this help screen"
echo -e "OPTIONS" printf "%s\n\t%s\t%s\n\t%s\t%s\n\t%s\t%s\n\t%s\t%s\n\t%s\t%s\n\t%s\t%s\n" "KEYBINDS" "space" "Reads the Pokedex entry" "ctrl-space" "Stops reading the Pokedex entry" "ctrl-n" "Shows small sprite version" "ctrl-b" "Shows large sprite version" "ctrl-s" "Shows shiny sprite version" "ctrl-h" "Shows this help screen in preview window"
echo -e "\t-q, --quick [pokemon]\n\t\tPrints single pokedex entry to terminal\n\t-u, --update [N/+N/-N/N%]\n\t\tScrape web for updated Pokemon stats\n\t\tWARNING: update function is resource heavy\n\t\tSee Parallel job control (-j) for options\n\t\tDefault is 200%\n\t-h, --help\n\t\tPrint this help screen"
echo -e "KEYBINDS"
echo -e "\tspace\tReads the Pokedex entry\n\tctrl-space Stops reading the Pokedex entry\n\tctrl-n\tShows small sprite version\n\tctrl-b\tShows large sprite version\n\tctrl-s\tShows shiny sprite version\n\tctrl-h\tShows this help screen in preview window\n"
} }
### Set pokeData location ### Set pokeData location
@ -34,7 +31,7 @@ pokedex() {
--preview-window=68%:wrap:border-rounded \ --preview-window=68%:wrap:border-rounded \
--bind=focus:transform-preview-label:'echo [ {1} ] ' \ --bind=focus:transform-preview-label:'echo [ {1} ] ' \
--bind=ctrl-h:preview:"echo; pokedex -h;" \ --bind=ctrl-h:preview:"echo; pokedex -h;" \
--bind=space:preview:"echo; pokemon-colorscripts -n {1} --no-title; cat $POKEDATA/{1}; espeak-ng -f $POKEDATA/{1} -g 2 -p 45 -s 160 -l 150 -ven+m3" \ --bind=space:preview:"echo; pokemon-colorscripts -n {1} --no-title; cat $POKEDATA/{1}; espeak-ng -f $POKEDATA/{1} -g 2 -p 45 -s 160 -l 150 -ven+m3 &" \
--bind=ctrl-space:preview:"echo; pokemon-colorscripts -n {1} --no-title; cat $POKEDATA/{1};" \ --bind=ctrl-space:preview:"echo; pokemon-colorscripts -n {1} --no-title; cat $POKEDATA/{1};" \
--bind=ctrl-b:preview:"echo; pokemon-colorscripts -b -n {1} --no-title; cat $POKEDATA/{1};" \ --bind=ctrl-b:preview:"echo; pokemon-colorscripts -b -n {1} --no-title; cat $POKEDATA/{1};" \
--bind=ctrl-s:preview:"echo; pokemon-colorscripts -s -n {1} --no-title; cat $POKEDATA/{1};" \ --bind=ctrl-s:preview:"echo; pokemon-colorscripts -s -n {1} --no-title; cat $POKEDATA/{1};" \
@ -42,7 +39,6 @@ pokedex() {
parallel pokemon-colorscripts --no-title -n {} "&&" cat "$POKEDATA/{}" parallel pokemon-colorscripts --no-title -n {} "&&" cat "$POKEDATA/{}"
} }
### Quick view returns single Pokemon stat instead of opening pokedex ### Quick view returns single Pokemon stat instead of opening pokedex
quick_view() { quick_view() {
parallel pokemon-colorscripts --no-title -n {} "&&" cat "$POKEDATA/{}" <<<"$1" parallel pokemon-colorscripts --no-title -n {} "&&" cat "$POKEDATA/{}" <<<"$1"
@ -50,28 +46,30 @@ quick_view() {
### Update Pokemon stats file set ### Update Pokemon stats file set
update_pokeData() { update_pokeData() {
echo -e "\n\t\tWARNING!!!\n\tThis WILL take a long time\n" printf "\n\t\t%s\n\t%s\n" "WARNING!!!" "This WILL take a long time"
pokemon-colorscripts -l | sort | parallel --bar --color --retry-failed -j "${1:-200%}" pokeInfo {} ">" "$POKEDATA/{}" 2>&1 pokemon-colorscripts -l | sort | parallel --bar --color --retry-failed -j "${1:-200%}" pokeInfo {} ">" "$POKEDATA/{}" 2>&1
} }
if [[ ! "$1" =~ ^- ]]; then if [[ ! "$1" =~ ^- ]]; then
pokedex "$1" pokedex "$1"
else else
for opt in "$@"; do while (( $# )); do
case $opt in arg=$1
shift
case "$arg" in
-q|--quick) -q|--quick)
quick_view "$2" quick_view "$1"
;; ;;
-u|--update) -u|--update)
update_pokeData "$2" update_pokeData "$1"
;; ;;
-h|--help) -h|--help)
help help
;; ;;
-*) -*)
echo "Invalid Usage" echo "Invalid Usage"
help help
;; ;;
esac esac
done done
fi fi