mirror of
https://github.com/danbulant/nekofetch
synced 2026-05-19 04:08:43 +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
|
||||
|
||||
tmpfile="$(mktemp)"
|
||||
imgurl="https://nekos.life/api/v2/img/neko"
|
||||
height="$(($(stty size | awk '{print $1}') - 5))"
|
||||
imgtype=""
|
||||
use_height=""
|
||||
|
||||
while :; do
|
||||
case "$1" in
|
||||
"--nsfw"|"nsfw"|"-n"|"n")
|
||||
[ "$DEBUG" = "true" ] && echo "Getting a nsfw image"
|
||||
imgurl="https://nekos.life/api/v2/img/cum_jpg"
|
||||
if [ "$imgtype" = "" ]; then
|
||||
[ "$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")
|
||||
[ "$DEBUG" = "true" ] && echo "Getting a sfw image"
|
||||
imgurl="https://nekos.life/api/v2/img/neko"
|
||||
if [ "$imgtype" = "" ]; then
|
||||
[ "$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")
|
||||
[ "$DEBUG" = "true" ] && echo "Using w3m image backend for neofetch"
|
||||
use_w3m="true"
|
||||
;;
|
||||
"--height"|"-h")
|
||||
height="$2"
|
||||
[ "$DEBUG" = "true" ] && echo "Using height $height"
|
||||
if [ "$use_height" = "" ]; then
|
||||
use_height="$2"
|
||||
[ "$DEBUG" = "true" ] && echo "Using height $height"
|
||||
else
|
||||
echo "You can only specify the height argument once!"
|
||||
fi
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
if [ -z "$1" ]; then
|
||||
break
|
||||
fi
|
||||
[ "$DEBUG" = "true" ] && echo "Could not interpret parameter '$1'."
|
||||
echo "Could not interpret parameter '$1'."
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
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")
|
||||
|
||||
curl -fsSLo "$tmpfile.jpg" "$url"
|
||||
|
|
|
|||
Loading…
Reference in a new issue