diff options
| author | Gregor Kleen <gkleen@yggdrasil.li> | 2016-03-01 10:20:31 +0100 |
|---|---|---|
| committer | Gregor Kleen <gkleen@yggdrasil.li> | 2016-03-01 10:20:31 +0100 |
| commit | f52ec2c8694b2e0ec4bce4c533cb930b68adf00b (patch) | |
| tree | cb937bb38fe1c0b0857d8204821dcddff661e68b | |
| parent | 1095c5fb127e5db2313ef2edddee0626c72ce648 (diff) | |
| download | thermoprint-f52ec2c8694b2e0ec4bce4c533cb930b68adf00b.tar thermoprint-f52ec2c8694b2e0ec4bce4c533cb930b68adf00b.tar.gz thermoprint-f52ec2c8694b2e0ec4bce4c533cb930b68adf00b.tar.bz2 thermoprint-f52ec2c8694b2e0ec4bce4c533cb930b68adf00b.tar.xz thermoprint-f52ec2c8694b2e0ec4bce4c533cb930b68adf00b.zip | |
drafts
| -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 |
