aboutsummaryrefslogtreecommitdiff
path: root/cli
diff options
context:
space:
mode:
authorIgor Pashev <pashev.igor@gmail.com>2015-11-01 19:46:30 +0300
committerIgor Pashev <pashev.igor@gmail.com>2015-11-01 19:47:46 +0300
commiteeb60821c73596fb3b1c2426bc26dbcd59eb7bb3 (patch)
treeb96990170dd19fb492c19d2e8e78e61e5520d2fc /cli
parentb09ba749840c0f7c363c1e831a2f6d60ec267b93 (diff)
downloadzerobin-eeb60821c73596fb3b1c2426bc26dbcd59eb7bb3.tar.gz
Support different bins
Diffstat (limited to 'cli')
-rw-r--r--cli/Main.hs24
1 files changed, 14 insertions, 10 deletions
diff --git a/cli/Main.hs b/cli/Main.hs
index e32a78f..81dda44 100644
--- a/cli/Main.hs
+++ b/cli/Main.hs
@@ -8,29 +8,32 @@ import System.Environment (getArgs)
import System.Exit (exitFailure)
import System.IO (stderr, hPutStrLn)
import Text.RawString.QQ (r)
-import ZeroBin (share, Expiration(..), pasteEc)
+import ZeroBin (share, Expiration(..))
import qualified Data.ByteString as BS
import qualified Data.ByteString.Char8 as C
import qualified System.Console.Docopt.NoTH as O
usage :: String
usage = "zerobin " ++ showVersion version
- ++ " pastes to " ++ pasteEc ++ [r|
+ ++ " pastes to 0bin services" ++ [r|
zerobin prints URI to be shared or error message
+See http://0bin.net and https://paste.ec
Usage:
zerobin [options] TEXT
Options:
- -e, --expire=E Set expiration of paste: once, day, week, month [default: week]
+ -b, --bin=BIN 0bin service [default: https://paste.ec]
-f, --file Paste the content of file TEXT instead of plain TEXT
+ -e, --expire=E Set expiration of paste: once, day, week, month [default: day]
-h, --help Show this message
Examples:
- zerobin hello paste "hello" for a week
- zerobin -f /etc/fstab paste file /etc/fstab for a week
- zerobin -e once hello paste "hello", it will burn after reading
+ zerobin hello paste "hello" for a day
+ zerobin -f /etc/fstab paste file /etc/fstab for a day
+ zerobin -e once hello paste "hello", it will burn after reading
+ zerobin -b http://0bin.net hello paste to 0bin.net
|]
@@ -58,18 +61,19 @@ getContent asFile text =
main :: IO ()
main = do
doco <- O.parseUsageOrExit usage
- args <- O.parseArgsOrExit doco =<< getArgs
+ args <- O.parseArgsOrExit doco =<< getArgs
if args `O.isPresent` O.longOption "help"
then putStrLn $ O.usage doco
else do
let get = O.getArgOrExitWith doco
+ bin <- args `get` O.longOption "bin"
expire <- args `get` O.longOption "expire"
text <- args `get` O.argument "TEXT"
cnt <- getContent (args `O.isPresent` O.longOption "file") text
case getExpiration expire of
- Nothing -> die "invalid value for expiration"
- Just e -> do
- rc <- share e cnt
+ Nothing -> die "invalid value for expiration"
+ Just e -> do
+ rc <- share bin e cnt
case rc of
Left err -> die err
Right uri -> putStrLn uri