function lhpaste() { local server_url="https://paste.linux-help.org" local o_apikey local o_expire=(--expire 60) local o_help local o_lang local o_name=(--name Psi-Jack) local o_private local o_reply local o_title local o_url=(--url https://paste.linux-help.org) local args if [[ -n "$LHPASTE_API_KEY" ]]; then o_apikey=(--apikey "$LHPASTE_API_KEY") fi if [[ -n "$LHPASTE_NAME" ]]; then o_name=(--name "$LHPASTE_NAME") fi zparseopts -D -K -M -- \ h=o_help -help=h \ e:=o_expire -expire:=e \ l:=o_lang -lang:=l \ n:=o_name -name:=n \ p=o_private -private=p \ r:=o_reply -reply:=r \ t:=o_title -title:=t \ u:=o_url -url:=u \ a:=o_apikey -apikey:=a if [[ -n "$o_help" ]]; then cat <<-EOF USAGE: $funcstack[1] [OPTIONS] [FILE] OPTIONS: --expire MIN, -e MIN Set paste expire time in minutes (Default: $o_expire[2]) --lang LANG, -l LANG Set paste language --name TEXT, -n TEXT Set paste author name (Default: $o_name[2]) --private, -p Set paste private --reply ID, -r ID Set paste in reply to ID --title TEXT, -t TEXT Set paste title text --url URL, -u URL Set paste server URL (Default: $o_url[2]) --apikey TEXT, -a TEXT Set API-KEY for Stikked Paste access EOF return 0 fi #echo "DEBUG:" #echo "expire = $o_expire[2]" #echo "lang = $o_lang[2]" #echo "name = $o_name[2]" #echo "help = $o_help" #echo "private = $o_private" #echo "reply = $o_reply[2]" #echo "title = $o_title[2]" #echo "url = $o_url[2]" #echo "apikey = $o_apikey[2]" if [[ -n "$o_expire" ]]; then args+=(-d "expire=$o_expire[2]") fi if [[ -n "$o_lang" ]]; then args+=(-d "lang=$o_lang[2]") fi if [[ -n "$o_name" ]]; then args+=(-d "name=$o_name[2]") fi if [[ -n "$o_private" ]]; then if [[ "$o_private" == "-p" || "$o_private" == "--private" || "$o_private" == "-p1" ]]; then args+=(-d "private=1") elif [[ "$o_private" == "-p0" ]]; then args+=(-d "private=0") fi fi if [[ -n "$o_reply" ]]; then args+=(-d "name=$o_reply[2]") fi if [[ -n "$o_title" ]]; then args+=(-d "name=$o_title[2]") fi #if [[ -n "$o_apikey" ]]; then # apikey="$o_apikey[2]" #fi if [[ -n "$o_url" ]]; then server_url="$o_url[2]/api/create" if [[ -n "$o_apikey" ]]; then server_url="$server_url?apikey=$o_apikey[2]" fi fi #echo "args = $args" #echo "opts = $*" #return 0 if [[ -t 1 ]]; then if test $# = 0; then if test -t 0; then echo "Missing filename" 1>&2 return fi curl $args --data-urlencode text@- "$server_url" else curl $args --data-urlencode text@"$1" "$server_url" fi else if test $# = 0; then if test -t 0; then echo "Missing filename" 1>&2 return fi curl $args --data-urlencode text@- "$server_url" else curl $args --data-urlencode text@"$1" "$server_url" fi fi }