From eeb60821c73596fb3b1c2426bc26dbcd59eb7bb3 Mon Sep 17 00:00:00 2001 From: Igor Pashev Date: Sun, 1 Nov 2015 19:46:30 +0300 Subject: Support different bins --- cli/Main.hs | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) (limited to 'cli/Main.hs') 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 -- cgit v1.2.3