karahti/karahti

54 lines
797 B
Plaintext
Raw Normal View History

2020-07-02 07:23:20 +00:00
#!/usr/bin/env bash
has() {
if (( $# )); then
hash "$1" 2>/dev/null
else
return 1
fi
}
for prog in curl; do
if ! has "$prog"; then
printf 'please install %s\n' "$prog" >&2
exit 1
fi
done
declare -A opts
while (( $# )); do
case $1 in
--*=*)
key=${1#--} key=${key%%=*}
val=${1#--"$key"=}
opts[$key]=$val
;;
--no-*)
opts[${1#--no-}]=false
;;
--)
shift
break
;;
--*)
opts[${1#--}]=true
;;
*)
break
;;
esac
shift
done
tail -n +1 -- "$@" | {
paste=$(
curl -sSA karahti/1.0 -w "%{redirect_url}" -F "paste_content=<-" \
-F "language=${opts[lang]:-auto}" -F "expiry=${opts[expire]}" \
https://p.ahti.space/nanopaste-get.cgi
)
printf "%s\n" "$paste"
}