From 1774f95a5c658cea2850e54c7cb164f4ad62e58d Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Tue, 1 Mar 2016 10:34:06 +0100 Subject: jobContent --- tprint/src/Main.hs | 9 +++++++++ tprint/tprint.cabal | 1 + tprint/tprint.nix | 7 ++++--- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/tprint/src/Main.hs b/tprint/src/Main.hs index 44cc2f6..f0f0186 100644 --- a/tprint/src/Main.hs +++ b/tprint/src/Main.hs @@ -7,6 +7,7 @@ import Data.Sequence (Seq) import qualified Data.Sequence as Seq import Data.Text (Text) import qualified Data.Text as T +import qualified Data.Text.IO as T import qualified Data.ByteString.Lazy.Char8 as Lazy (ByteString) import qualified Data.ByteString.Lazy.Char8 as LCBS import Data.Time @@ -15,14 +16,17 @@ import Data.Foldable import Data.List import Data.Monoid import Data.Maybe +import Data.Either import Control.Monad +import Control.Monad.Catch import Text.Show.Pretty (dumpStr) import Data.Aeson.Encode.Pretty (encodePretty) import System.IO +import Thermoprint.Printout.BBCode import Thermoprint.Client import Options @@ -67,6 +71,11 @@ tprint TPrint{ operation = Drafts, ..} Client{..} out = drafts >>= format | (Human, _) <- output = mapM_ (\(DraftId n, fromMaybe "" . fmap T.unpack -> t) -> hPutStrLn out $ show n ++ "\t" ++ t) $ Map.toAscList ds | (JSON, _) <- output = LCBS.hPutStrLn out $ encodePretty ds | otherwise = hPutStrLn out . dumpStr $ Map.toAscList ds + +tprint TPrint{ operation = Job{..}, ..} Client{..} out = job jobId >>= format + where format p + | (JSON, _) <- output = LCBS.hPutStrLn out $ encodePretty p + | otherwise <- output = T.hPutStrLn out =<< either throwM return (cobbcode p) tprint _ _ _ = undefined diff --git a/tprint/tprint.cabal b/tprint/tprint.cabal index 9531665..03d6352 100644 --- a/tprint/tprint.cabal +++ b/tprint/tprint.cabal @@ -32,6 +32,7 @@ executable tprint , text >=1.2.2 && <2 , aeson-pretty >=0.7.2 && <1 , bytestring >=0.10.6 && <1 + , exceptions >=0.8.2 && <1 hs-source-dirs: src default-language: Haskell2010 ghc-options: -Wall \ No newline at end of file diff --git a/tprint/tprint.nix b/tprint/tprint.nix index e28204d..ace6210 100644 --- a/tprint/tprint.nix +++ b/tprint/tprint.nix @@ -1,5 +1,5 @@ { mkDerivation, aeson-pretty, base, bytestring, containers -, optparse-applicative, pretty-show, stdenv, text +, exceptions, optparse-applicative, pretty-show, stdenv, text , thermoprint-bbcode, thermoprint-client, time }: mkDerivation { @@ -9,8 +9,9 @@ mkDerivation { isLibrary = false; isExecutable = true; executableHaskellDepends = [ - aeson-pretty base bytestring containers optparse-applicative - pretty-show text thermoprint-bbcode thermoprint-client time + aeson-pretty base bytestring containers exceptions + optparse-applicative pretty-show text thermoprint-bbcode + thermoprint-client time ]; homepage = "http://dirty-haskell.org/tags/thermoprint.html"; description = "A CLI for thermoprint-client"; -- cgit v1.2.3