aboutsummaryrefslogtreecommitdiff
path: root/cli
diff options
context:
space:
mode:
authorIgor Pashev <pashev.igor@gmail.com>2016-02-29 12:34:25 +0800
committerIgor Pashev <pashev.igor@gmail.com>2016-02-29 12:34:25 +0800
commit718a348afaf6a78a0f0074330d03ac410f487a50 (patch)
tree55e03c94baada32c8eed703d97966b9607af2bad /cli
parent6de363c133f3f5dbc9c6b80dc5ac87c7ec76b8d5 (diff)
downloadzerobin-718a348afaf6a78a0f0074330d03ac410f487a50.tar.gz
zerobin -f - reads stdin
Diffstat (limited to 'cli')
-rw-r--r--cli/Main.hs12
1 files changed, 6 insertions, 6 deletions
diff --git a/cli/Main.hs b/cli/Main.hs
index bcd7d54..9e5641b 100644
--- a/cli/Main.hs
+++ b/cli/Main.hs
@@ -24,7 +24,7 @@ Usage:
Options:
-b, --bin=BIN 0bin service [default: https://paste.ec]
- -f, --file Paste the content of file TEXT instead of plain TEXT
+ -f, --file Paste the content of file TEXT ("-" for stdin)
-e, --expire=E Set expiration of paste: once, day, week, month [default: day]
-h, --help Show this message
@@ -32,6 +32,7 @@ Options:
Examples:
zerobin hello paste "hello" for a day
zerobin -f /etc/fstab paste file /etc/fstab for a day
+ cat /etc/fstab | zerobin -f - likewise
zerobin -e once hello paste "hello", it will burn after reading
zerobin -b http://0bin.net hello paste to 0bin.net
|]
@@ -52,11 +53,10 @@ die msg = do
exitFailure
getContent :: Bool -> String -> IO BS.ByteString
-getContent asFile text =
- if not asFile
- then return $ C.pack text
- else BS.readFile text
-
+getContent fromFile text
+ | fromFile && (text == "-") = BS.getContents
+ | fromFile = BS.readFile text
+ | otherwise = return $ C.pack text
main :: IO ()
main = do