diff options
-rw-r--r-- | tprint/src/Main.hs | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/tprint/src/Main.hs b/tprint/src/Main.hs index ce4df20..44cc2f6 100644 --- a/tprint/src/Main.hs +++ b/tprint/src/Main.hs | |||
@@ -14,6 +14,7 @@ import Data.Time | |||
14 | import Data.Foldable | 14 | import Data.Foldable |
15 | import Data.List | 15 | import Data.List |
16 | import Data.Monoid | 16 | import Data.Monoid |
17 | import Data.Maybe | ||
17 | 18 | ||
18 | import Control.Monad | 19 | import Control.Monad |
19 | 20 | ||
@@ -61,5 +62,11 @@ tprint TPrint{ operation = Jobs{..}, ..} Client{..} out = jobs printer jobRange | |||
61 | humanStatus (Done) _ = "finished successfully" | 62 | humanStatus (Done) _ = "finished successfully" |
62 | humanStatus (Failed err) _ = "failed: " ++ show err | 63 | humanStatus (Failed err) _ = "failed: " ++ show err |
63 | 64 | ||
65 | tprint TPrint{ operation = Drafts, ..} Client{..} out = drafts >>= format | ||
66 | where format ds | ||
67 | | (Human, _) <- output = mapM_ (\(DraftId n, fromMaybe "" . fmap T.unpack -> t) -> hPutStrLn out $ show n ++ "\t" ++ t) $ Map.toAscList ds | ||
68 | | (JSON, _) <- output = LCBS.hPutStrLn out $ encodePretty ds | ||
69 | | otherwise = hPutStrLn out . dumpStr $ Map.toAscList ds | ||
70 | |||
64 | 71 | ||
65 | tprint _ _ _ = undefined | 72 | tprint _ _ _ = undefined |