update pokedex for dev branch
This commit is contained in:
parent
fd00e28387
commit
ff0da23f4b
81
pokedex
81
pokedex
|
@ -1,19 +1,27 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
### Overhad preparation
|
||||||
|
KBINDS="/usr/share/fuzzy-pokedex/keybindings-preview"
|
||||||
|
POKEDATA="./pokeData"
|
||||||
|
|
||||||
### 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" "EXAMPLE" "pokedex [pokemon name]"
|
||||||
echo -e "EXAMPLE\n\tpokedex [pokemon name]\n"
|
printf "%s\n" "OPTIONS"
|
||||||
echo -e "OPTIONS"
|
printf "%-25s\t%s\n" " -q, --quick [pokemon]" "Prints single pokedex entry to terminal" \
|
||||||
echo -e "\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"
|
" -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%" \
|
||||||
echo -e "KEYBINDS"
|
" -h, --help" "Print this help screen"
|
||||||
echo -e "\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"
|
printf "\n%s\n" "KEYBINDS"
|
||||||
|
printf "%-15s\t%s\n" " 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"
|
||||||
|
printf "\n"
|
||||||
}
|
}
|
||||||
|
|
||||||
### Set pokeData location
|
|
||||||
POKEDATA="./pokeData/"
|
|
||||||
|
|
||||||
### Pokedex viewer using pokemon-colorscripts and fzf
|
### Pokedex viewer using pokemon-colorscripts and fzf
|
||||||
pokedex() {
|
pokedex() {
|
||||||
pokemon-colorscripts -l |
|
pokemon-colorscripts -l |
|
||||||
|
@ -26,47 +34,54 @@ pokedex() {
|
||||||
--border-label="╢ Fuzzy-Pokedex ╟" \
|
--border-label="╢ Fuzzy-Pokedex ╟" \
|
||||||
--margin=4% \
|
--margin=4% \
|
||||||
--padding=4% \
|
--padding=4% \
|
||||||
--header="$(echo -e 'Choose a Pokemon to view\n ctrl+h to for help')" \
|
--header="$(echo -e ' Choose a Pokemon to view info\n\t ctrl+h to for help')" \
|
||||||
--info=inline:' ' \
|
--info=inline:' ' \
|
||||||
--color='fg+:15,fg:42,preview-fg:15,label:9,preview-label:15,hl+:134,hl:123,query:134,gutter:0,border:9,prompt:15,pointer:15,marker:15' \
|
--color='fg+:15,fg:42,preview-fg:15,label:9,preview-label:15,hl+:134,hl:123,query:134,gutter:0,border:9,prompt:15,pointer:15,marker:15' \
|
||||||
--tiebreak=begin,chunk,length \
|
--tiebreak=begin,chunk,length \
|
||||||
--preview="printf '\n\t\t\t\t\t%s\n\t\t\t\t\t %s\n' 'Press space to hear entry' 'ctrl+space to stop'; pokemon-colorscripts -n {1} --no-title; cat $POKEDATA{1}" \
|
--preview="printf '\n\t\t\t\t\t%s\n\t\t\t\t\t %s\n' 'Press space to hear entry' 'ctrl+space to stop'; pokemon-colorscripts -n {1} --no-title; cat $POKEDATA/{1}" \
|
||||||
--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:"cat $KBINDS" \
|
||||||
--bind=space:preview:"echo; pokemon-colorscripts -n {1} --no-title; cat $POKEDATA/{1}; espeak-ng -f $POKEDATA/{1} -g 4 -p 50 -s 145 -l 250 -ven+m3 &" \
|
--bind=space:preview:"printf '\n\t\t\t\t %s\n\t\t\t\t\t %s\n' 'Select another Pokemon to stop audio' 'Or press ctrl+space'; pokemon-colorscripts -n {1} --no-title; cat $POKEDATA/{1}; espeak-ng -f $POKEDATA/{1} -g 4 -p 50 -s 145 -l 250 -ven+m3 &" \
|
||||||
--bind=ctrl-space:preview:"echo; pokemon-colorscripts -n {1} --no-title; cat $POKEDATA/{1};" \
|
--bind=ctrl-space:preview:"printf '\n\t\t\t\t\t%s\n\t\t\t\t\t %s\n' 'Press space to hear entry' 'ctrl+space to stop'; 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};" \
|
||||||
--bind=ctrl-n:preview:"echo; pokemon-colorscripts -n {1} --no-title; cat $POKEDATA{1};" |
|
--bind=ctrl-n:preview:"printf '\n\t\t\t\t\t%s\n\t\t\t\t\t %s\n' 'Press space to hear entry' 'ctrl+space to stop'; pokemon-colorscripts -n {1} --no-title; cat $POKEDATA/{1};" |
|
||||||
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() {
|
||||||
|
parallel pokemon-colorscripts --no-title -n {} "&&" cat "$POKEDATA/{}" <<<"$1"
|
||||||
}
|
}
|
||||||
|
|
||||||
### 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\n" "WARNING!!!" "This WILL take a long time"
|
||||||
if [[ -n "$1" ]]; then
|
pokemon-colorscripts -l | sort | parallel --progress --bar --color --retry-failed -j "${1:-200%}" pokeInfo {} ">" "$POKEDATA/{}" 2>&1
|
||||||
pokemon-colorscripts -l | sort | parallel --bar --color --retry-failed -j "$1" pokeInfo {} ">" "$POKEDATA"{}
|
|
||||||
else
|
|
||||||
pokemon-colorscripts -l | sort | parallel --bar --color --retry-failed -j 200% pokeInfo {} ">" "$POKEDATA"{}
|
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
### Arg parsing loop
|
||||||
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)
|
||||||
|
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
|
||||||
|
|
Loading…
Reference in New Issue