From c6239c19425b92724b09d7965e212a0ed856a609 Mon Sep 17 00:00:00 2001 From: Igor Pashev Date: Tue, 10 Oct 2017 16:11:34 +0300 Subject: Use hindent --- cli/Main.hs | 51 +++++++++++++++++++++++++++------------------------ 1 file changed, 27 insertions(+), 24 deletions(-) (limited to 'cli') diff --git a/cli/Main.hs b/cli/Main.hs index 643fd5f..f40966c 100644 --- a/cli/Main.hs +++ b/cli/Main.hs @@ -1,21 +1,26 @@ {-# LANGUAGE QuasiQuotes #-} -module Main where +module Main + ( main + ) where +import qualified Data.ByteString as BS +import qualified Data.ByteString.Char8 as C import Data.Version (showVersion) import Paths_zerobin (version) -- from cabal +import qualified System.Console.Docopt.NoTH as O import System.Environment (getArgs) import System.Exit (exitFailure) -import System.IO (stderr, hPutStrLn) +import System.IO (hPutStrLn, stderr) import Text.RawString.QQ (r) -import Web.ZeroBin (share, Expiration(..)) -import qualified Data.ByteString as BS -import qualified Data.ByteString.Char8 as C -import qualified System.Console.Docopt.NoTH as O +import Web.ZeroBin (Expiration(..), share) usage :: String -usage = "zerobin " ++ showVersion version - ++ " pastes to 0bin services" ++ [r| +usage = + "zerobin " ++ + showVersion version ++ + " pastes to 0bin services" ++ + [r| zerobin prints URI to be shared or error message See http://0bin.net and https://paste.ec @@ -37,15 +42,14 @@ Examples: zerobin -b http://0bin.net hello paste to 0bin.net |] - getExpiration :: String -> Maybe Expiration getExpiration e = case e of - "once" -> Just Once - "day" -> Just Day - "week" -> Just Week + "once" -> Just Once + "day" -> Just Day + "week" -> Just Week "month" -> Just Month - _ -> Nothing + _ -> Nothing die :: String -> IO () die msg = do @@ -63,14 +67,13 @@ main = do doco <- O.parseUsageOrExit usage 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 -> share bin e cnt >>= putStrLn - + 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 -> share bin e cnt >>= putStrLn -- cgit v1.2.3