abc05fa422a183e974df9faefc61a8512abe1db9

Author
Noah Nichols <noahjacknichols@gmail.com>
Committer
Marc Cornellà <marc.cornella@live.com>
Date

Message

sprunge: add README and refactor (#8239)

Co-authored-by: Marc Cornellà <marc.cornella@live.com>

Diff

This diff is truncated to protect this page.

 1diff --git a/plugins/sprunge/README.md b/plugins/sprunge/README.md
 2new file mode 100644
 3index 0000000000000000000000000000000000000000..2a363d3bd93a9c296a546ee96f842b74ee3de32b
 4--- /dev/null
 5+++ b/plugins/sprunge/README.md
 6@@ -0,0 +1,31 @@
 7+# Sprunge plugin
 8+
 9+This plugin uploads data and fetch URL from the pastebin http://sprunge.us
10+
11+To enable it, add 'sprunge' to your plugins:
12+```
13+plugins=(... sprunge)
14+```
15+
16+## Usage
17+
18+| Command                      | Description                               |
19+|------------------------------|-------------------------------------------|
20+| `sprunge filename.txt`       | Uploads filename.txt                      |
21+| `sprunge "this is a string"` | Uploads plain text                        |
22+| `sprunge < filename.txt`     | Redirects filename.txt content to sprunge |
23+| `echo data \| sprunge`       | Any piped data will be uploaded           |
24+
25+Once sprunge has processed the input it will give you a unique HTTP address:
26+```
27+$ sprunge "hello"
28+http://sprunge.us/XxjnKz
29+```
30+
31+## Notes
32+
33+- Sprunge accepts piped data, stdin redirection, text strings as input or filenames.
34+  Only one of these can be used at a time.
35+- Argument precedence goes as follows: stdin > piped input > text strings.
36+- If a filename is mispelled or doesn't have the necessary path description, it will NOT
37+  generate an error, but instead treat it as a text string.
38diff --git a/plugins/sprunge/sprunge.plugin.zsh b/plugins/sprunge/sprunge.plugin.zsh
39index e1c89b729202dfad708d3296ed2359a451203c84..5d5687a8264274b370e6479511e3cb013ceaa71f 100644
40--- a/plugins/sprunge/sprunge.plugin.zsh
41+++ b/plugins/sprunge/sprunge.plugin.zsh
42@@ -2,12 +2,9 @@
43 # Created by the blogger at the URL below...I don't know where to find his/her name
44 # Original found at https://www.shellperson.net/sprunge-pastebin-script/
45 
46-usage() {
47-description | fmt -s >&2
48-}
49-
50-description() {
51-cat << HERE
52+sprunge() {
53+  if [[ "$1" = --help ]]; then
54+    fmt -s >&2 << EOF
55 
56 DESCRIPTION
57   Upload data and fetch URL from the pastebin http://sprunge.us
58@@ -19,44 +16,41 @@ USAGE
59   piped_data | $0
60 
61 NOTES
62---------------------------------------------------------------------------
63-* INPUT METHODS *