mirror of
https://github.com/danbulant/nekofetch
synced 2026-05-27 05:42:34 +00:00
Warn if an argument is passed more than once
also respect the first passed argument of its kind only
This commit is contained in:
parent
57a29f12b4
commit
f461cbb3a2
1 changed files with 33 additions and 9 deletions
42
nekofetch
42
nekofetch
|
|
@ -1,38 +1,62 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
tmpfile="$(mktemp)"
|
tmpfile="$(mktemp)"
|
||||||
imgurl="https://nekos.life/api/v2/img/neko"
|
imgtype=""
|
||||||
height="$(($(stty size | awk '{print $1}') - 5))"
|
use_height=""
|
||||||
|
|
||||||
while :; do
|
while :; do
|
||||||
case "$1" in
|
case "$1" in
|
||||||
"--nsfw"|"nsfw"|"-n"|"n")
|
"--nsfw"|"nsfw"|"-n"|"n")
|
||||||
[ "$DEBUG" = "true" ] && echo "Getting a nsfw image"
|
if [ "$imgtype" = "" ]; then
|
||||||
imgurl="https://nekos.life/api/v2/img/cum_jpg"
|
[ "$DEBUG" = "true" ] && echo "Getting a nsfw image"
|
||||||
|
imgtype="nsfw"
|
||||||
|
else
|
||||||
|
echo "$imgtype images were already chosen! Please only specify either sfw or nsfw!"
|
||||||
|
fi
|
||||||
;;
|
;;
|
||||||
"--sfw"|"sfw"|"-s"|"s")
|
"--sfw"|"sfw"|"-s"|"s")
|
||||||
[ "$DEBUG" = "true" ] && echo "Getting a sfw image"
|
if [ "$imgtype" = "" ]; then
|
||||||
imgurl="https://nekos.life/api/v2/img/neko"
|
[ "$DEBUG" = "true" ] && echo "Getting a sfw image"
|
||||||
|
imgtype="sfw"
|
||||||
|
else
|
||||||
|
echo "$imgtype images were already chosen! Please only specify either sfw or nsfw!"
|
||||||
|
fi
|
||||||
;;
|
;;
|
||||||
"--w3m"|"w3m"|"--img"|"img"|"-i"|"i")
|
"--w3m"|"w3m"|"--img"|"img"|"-i"|"i")
|
||||||
[ "$DEBUG" = "true" ] && echo "Using w3m image backend for neofetch"
|
[ "$DEBUG" = "true" ] && echo "Using w3m image backend for neofetch"
|
||||||
use_w3m="true"
|
use_w3m="true"
|
||||||
;;
|
;;
|
||||||
"--height"|"-h")
|
"--height"|"-h")
|
||||||
height="$2"
|
if [ "$use_height" = "" ]; then
|
||||||
[ "$DEBUG" = "true" ] && echo "Using height $height"
|
use_height="$2"
|
||||||
|
[ "$DEBUG" = "true" ] && echo "Using height $height"
|
||||||
|
else
|
||||||
|
echo "You can only specify the height argument once!"
|
||||||
|
fi
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
if [ -z "$1" ]; then
|
if [ -z "$1" ]; then
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
[ "$DEBUG" = "true" ] && echo "Could not interpret parameter '$1'."
|
echo "Could not interpret parameter '$1'."
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
shift
|
shift
|
||||||
done
|
done
|
||||||
|
|
||||||
|
if [ "$imgtype" = "nsfw" ]; then
|
||||||
|
imgurl="https://nekos.life/api/v2/img/cum_jpg"
|
||||||
|
else
|
||||||
|
imgurl="https://nekos.life/api/v2/img/neko"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$use_height" != "" ]; then
|
||||||
|
height="$use_height"
|
||||||
|
else
|
||||||
|
height="$(($(stty size | awk '{print $1}') - 5))"
|
||||||
|
fi
|
||||||
|
|
||||||
url=$(curl -fsSL "$imgurl" | jq -r ".url")
|
url=$(curl -fsSL "$imgurl" | jq -r ".url")
|
||||||
|
|
||||||
curl -fsSLo "$tmpfile.jpg" "$url"
|
curl -fsSLo "$tmpfile.jpg" "$url"
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue