#!/bin/sh

required="neofetch jp2a jq"

for req in $required; do
    ! command -v "$req" > /dev/null 2>&1 && echo "$req not found!" && exit 1
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

curl -fsSLo "$tmpfile.jpg" "$url"
jp2a "$tmpfile.jpg" > "$tmpfile"
neofetch --source "$tmpfile"

rm "$tmpfile" "$tmpfile.jpg"
