diff options
Diffstat (limited to 'tprint/src')
-rw-r--r-- | tprint/src/Main.hs | 9 |
1 files changed, 9 insertions, 0 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) | |||
7 | import qualified Data.Sequence as Seq | 7 | import qualified Data.Sequence as Seq |
8 | import Data.Text (Text) | 8 | import Data.Text (Text) |
9 | import qualified Data.Text as T | 9 | import qualified Data.Text as T |
10 | import qualified Data.Text.IO as T | ||
10 | import qualified Data.ByteString.Lazy.Char8 as Lazy (ByteString) | 11 | import qualified Data.ByteString.Lazy.Char8 as Lazy (ByteString) |
11 | import qualified Data.ByteString.Lazy.Char8 as LCBS | 12 | import qualified Data.ByteString.Lazy.Char8 as LCBS |
12 | import Data.Time | 13 | import Data.Time |
@@ -15,14 +16,17 @@ import Data.Foldable | |||
15 | import Data.List | 16 | import Data.List |
16 | import Data.Monoid | 17 | import Data.Monoid |
17 | import Data.Maybe | 18 | import Data.Maybe |
19 | import Data.Either | ||
18 | 20 | ||
19 | import Control.Monad | 21 | import Control.Monad |
22 | import Control.Monad.Catch | ||
20 | 23 | ||
21 | import Text.Show.Pretty (dumpStr) | 24 | import Text.Show.Pretty (dumpStr) |
22 | import Data.Aeson.Encode.Pretty (encodePretty) | 25 | import Data.Aeson.Encode.Pretty (encodePretty) |
23 | 26 | ||
24 | import System.IO | 27 | import System.IO |
25 | 28 | ||
29 | import Thermoprint.Printout.BBCode | ||
26 | import Thermoprint.Client | 30 | import Thermoprint.Client |
27 | import Options | 31 | import Options |
28 | 32 | ||
@@ -67,6 +71,11 @@ tprint TPrint{ operation = Drafts, ..} Client{..} out = drafts >>= format | |||
67 | | (Human, _) <- output = mapM_ (\(DraftId n, fromMaybe "" . fmap T.unpack -> t) -> hPutStrLn out $ show n ++ "\t" ++ t) $ Map.toAscList ds | 71 | | (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 | 72 | | (JSON, _) <- output = LCBS.hPutStrLn out $ encodePretty ds |
69 | | otherwise = hPutStrLn out . dumpStr $ Map.toAscList ds | 73 | | otherwise = hPutStrLn out . dumpStr $ Map.toAscList ds |
74 | |||
75 | tprint TPrint{ operation = Job{..}, ..} Client{..} out = job jobId >>= format | ||
76 | where format p | ||
77 | | (JSON, _) <- output = LCBS.hPutStrLn out $ encodePretty p | ||
78 | | otherwise <- output = T.hPutStrLn out =<< either throwM return (cobbcode p) | ||
70 | 79 | ||
71 | 80 | ||
72 | tprint _ _ _ = undefined | 81 | tprint _ _ _ = undefined |