added dpaste.sh, simple CLI client
1 files changed, 44 insertions(+), 0 deletions(-)

A => dpaste.sh
A => dpaste.sh +44 -0
@@ 0,0 1,44 @@ 
+#!/bin/sh
+# Adapted from http://mywiki.wooledge.org/BashFAQ/035#getopts
+
+# Usage info
+show_help() {
+cat << HELP
+Usage: ${0#*/} [-h] [-s SYNTAX] [-t TITLE] [-p POSTER] [-e EXPIRY]
+Send stdin to dpaste.com, optionally with syntax/title/poster/expiry specified.
+Resulting item will be opened in your browser.
+HELP
+}
+
+# Process the options
+params=""
+# Trailing colon on option name means it expects a value
+while getopts hs:t:p:e: opt; do
+    case $opt in
+        h)
+            show_help
+            exit 0
+            ;;
+        s)  params="$params -F syntax=$OPTARG"
+            ;;
+        t)  params="$params -F title=$OPTARG"
+            ;;
+        p)  params="$params -F poster=$OPTARG"
+            ;;
+        e)  params="$params -F expiry_days=$OPTARG"
+            ;;
+        *)
+            show_help >&2
+            exit 1
+            ;;
+    esac
+done
+shift "$((OPTIND-1))"
+
+echo "Paste your content now, ^D to submit.\n---"
+
+# make the API call
+url=$(curl -s -F "content=<-" $params http://dpaste.com/api/v2/)
+# open the resulting paste
+open $url
+