From 0a8bbb0c2de978a7651bb3f5f5b026e76d97ecd9 Mon Sep 17 00:00:00 2001 From: BBaoVanC Date: Sat, 26 Dec 2020 15:43:09 -0600 Subject: [PATCH] Use a case statement for argument parsing --- nekofetch | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/nekofetch b/nekofetch index 119eaf1..72237ed 100755 --- a/nekofetch +++ b/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"