Add ahti paste client

This commit is contained in:
Nick Chambers 2020-07-02 02:23:20 -05:00
parent bdf8bd408f
commit 6da8accf45
1 changed files with 53 additions and 0 deletions

53
karahti Executable file
View File

@ -0,0 +1,53 @@
#!/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"
}