diff options
-rw-r--r-- | tprint/src/Main.hs | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/tprint/src/Main.hs b/tprint/src/Main.hs index 5734e68..bc5ee2f 100644 --- a/tprint/src/Main.hs +++ b/tprint/src/Main.hs | |||
@@ -90,31 +90,31 @@ tprint TPrint{ operation = Printers, ..} Client{..} out = printers >>= format | |||
90 | tprint TPrint{ operation = Jobs{..}, ..} Client{..} out = jobs printer jobRange timeRange >>= format | 90 | tprint TPrint{ operation = Jobs{..}, ..} Client{..} out = jobs printer jobRange timeRange >>= format |
91 | where format js | 91 | where format js |
92 | | (Human, _) <- output = mapM_ (\((JobId n), created, status) -> hPutStrLn out $ show n ++ "\t" ++ formatTime defaultTimeLocale "%Y-%m-%d %H:%M:%S %Z" created ++ "\t" ++ humanJobStatus status printer) . sortBy jSort $ toList js | 92 | | (Human, _) <- output = mapM_ (\((JobId n), created, status) -> hPutStrLn out $ show n ++ "\t" ++ formatTime defaultTimeLocale "%Y-%m-%d %H:%M:%S %Z" created ++ "\t" ++ humanJobStatus status printer) . sortBy jSort $ toList js |
93 | | (JSON, _) <- output = LCBS.hPutStrLn out $ encodePretty js | 93 | | (JSON, _) <- output = LCBS.hPutStrLn out $ encodePretty js |
94 | | otherwise = hPutStrLn out . dumpStr $ toList js | 94 | | otherwise = hPutStrLn out . dumpStr $ toList js |
95 | jSort (id, time, status) (id', time', status') = queueSort status status' <> compare time' time <> compare id id' | 95 | jSort (id, time, status) (id', time', status') = queueSort status status' <> compare time' time <> compare id id' |
96 | 96 | ||
97 | tprint TPrint{ operation = Drafts, ..} Client{..} out = drafts >>= format | 97 | tprint TPrint{ operation = Drafts, ..} Client{..} out = drafts >>= format |
98 | where format ds | 98 | where format ds |
99 | | (Human, _) <- output = mapM_ (\(DraftId n, fromMaybe "" . fmap T.unpack -> t) -> hPutStrLn out $ show n ++ "\t" ++ t) $ Map.toAscList ds | 99 | | (Human, _) <- output = mapM_ (\(DraftId n, fromMaybe "" . fmap T.unpack -> t) -> hPutStrLn out $ show n ++ "\t" ++ t) $ Map.toAscList ds |
100 | | (JSON, _) <- output = LCBS.hPutStrLn out $ encodePretty ds | 100 | | (JSON, _) <- output = LCBS.hPutStrLn out $ encodePretty ds |
101 | | otherwise = hPutStrLn out . dumpStr $ Map.toAscList ds | 101 | | otherwise = hPutStrLn out . dumpStr $ Map.toAscList ds |
102 | 102 | ||
103 | tprint TPrint{ operation = JobStatus{..}, ..} Client{..} out = jobStatus jobId >>= format | 103 | tprint TPrint{ operation = JobStatus{..}, ..} Client{..} out = jobStatus jobId >>= format |
104 | where format s | 104 | where format s |
105 | | (Human, _) <- output = hPutStrLn out $ humanJobStatus s Nothing | 105 | | (Human, _) <- output = hPutStrLn out $ humanJobStatus s Nothing |
106 | | (JSON, _) <- output = LCBS.hPutStrLn out $ encodePretty s | 106 | | (JSON, _) <- output = LCBS.hPutStrLn out $ encodePretty s |
107 | | otherwise = hPutStrLn out $ dumpStr s | 107 | | otherwise = hPutStrLn out $ dumpStr s |
108 | 108 | ||
109 | tprint TPrint{ operation = Job{..}, ..} Client{..} out = job jobId >>= format | 109 | tprint TPrint{ operation = Job{..}, ..} Client{..} out = job jobId >>= format |
110 | where format p | 110 | where format p |
111 | | (JSON, _) <- output = LCBS.hPutStrLn out $ encodePretty p | 111 | | (JSON, _) <- output = LCBS.hPutStrLn out $ encodePretty p |
112 | | otherwise = T.hPutStrLn out =<< either throwM return (cobbcode p) | 112 | | otherwise = T.hPutStrLn out =<< either throwM return (cobbcode p) |
113 | 113 | ||
114 | tprint TPrint{ operation = Draft{..}, ..} Client{..} out = draft draftId >>= format | 114 | tprint TPrint{ operation = Draft{..}, ..} Client{..} out = draft draftId >>= format |
115 | where format d@(fromMaybe "" . fmap T.unpack -> t, p) | 115 | where format d@(fromMaybe "" . fmap T.unpack -> t, p) |
116 | | (JSON, _) <- output = LCBS.hPutStrLn out $ encodePretty d | 116 | | (JSON, _) <- output = LCBS.hPutStrLn out $ encodePretty d |
117 | | otherwise = do | 117 | | otherwise = do |
118 | hPutStrLn out t | 118 | hPutStrLn out t |
119 | hPutStrLn out "" | 119 | hPutStrLn out "" |
120 | T.hPutStrLn out =<< either throwM return (cobbcode p) | 120 | T.hPutStrLn out =<< either throwM return (cobbcode p) |