mirror of
https://github.com/danbulant/nekofetch
synced 2026-06-17 13:21:12 +00:00
Use a case statement for argument parsing
This commit is contained in:
parent
c6e1f07bbe
commit
0a8bbb0c2d
1 changed files with 12 additions and 5 deletions
17
nekofetch
17
nekofetch
|
|
@ -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"
|
||||
|
|
|
|||
Loading…
Reference in a new issue