Use a case statement for argument parsing

This commit is contained in:
BBaoVanC 2020-12-26 15:43:09 -06:00
parent c6e1f07bbe
commit 0a8bbb0c2d
No known key found for this signature in database
GPG key ID: 18089E4E3CCF1D3A

View file

@ -9,11 +9,18 @@ done
tmpfile="$(mktemp -p /tmp nekofetchXXXXXXXX)"
if [ "$1" = "--nsfw" ]; then
url=$(curl -fsSL "https://nekos.life/api/v2/img/cum_jpg" | jq -r ".url")
else
url=$(curl -fsSL "https://nekos.life/api/v2/img/neko" | jq -r ".url")
fi
case "$1" in
"--nsfw")
echo "Getting a nsfw image"
imgurl="https://nekos.life/api/v2/img/cum_jpg"
;;
*)
echo "Getting a sfw image"
imgurl="https://nekos.life/api/v2/img/neko"
;;
esac
url=$(curl -fsSL "$imgurl" | jq -r ".url")
curl -fsSLo "$tmpfile.jpg" "$url"
jp2a "$tmpfile.jpg" > "$tmpfile"