diff options
author | Gregor Kleen <gkleen@yggdrasil.li> | 2016-03-01 10:34:06 +0100 |
---|---|---|
committer | Gregor Kleen <gkleen@yggdrasil.li> | 2016-03-01 10:34:06 +0100 |
commit | 1774f95a5c658cea2850e54c7cb164f4ad62e58d (patch) | |
tree | c95940daecc9fa74e5a5cf53e68b7680150db8c2 /tprint | |
parent | f52ec2c8694b2e0ec4bce4c533cb930b68adf00b (diff) | |
download | thermoprint-1774f95a5c658cea2850e54c7cb164f4ad62e58d.tar thermoprint-1774f95a5c658cea2850e54c7cb164f4ad62e58d.tar.gz thermoprint-1774f95a5c658cea2850e54c7cb164f4ad62e58d.tar.bz2 thermoprint-1774f95a5c658cea2850e54c7cb164f4ad62e58d.tar.xz thermoprint-1774f95a5c658cea2850e54c7cb164f4ad62e58d.zip |
jobContent
Diffstat (limited to 'tprint')
-rw-r--r-- | tprint/src/Main.hs | 9 | ||||
-rw-r--r-- | tprint/tprint.cabal | 1 | ||||
-rw-r--r-- | 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) | |||
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 |
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 | |||
32 | , text >=1.2.2 && <2 | 32 | , text >=1.2.2 && <2 |
33 | , aeson-pretty >=0.7.2 && <1 | 33 | , aeson-pretty >=0.7.2 && <1 |
34 | , bytestring >=0.10.6 && <1 | 34 | , bytestring >=0.10.6 && <1 |
35 | , exceptions >=0.8.2 && <1 | ||
35 | hs-source-dirs: src | 36 | hs-source-dirs: src |
36 | default-language: Haskell2010 | 37 | default-language: Haskell2010 |
37 | ghc-options: -Wall \ No newline at end of file | 38 | 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 @@ | |||
1 | { mkDerivation, aeson-pretty, base, bytestring, containers | 1 | { mkDerivation, aeson-pretty, base, bytestring, containers |
2 | , optparse-applicative, pretty-show, stdenv, text | 2 | , exceptions, optparse-applicative, pretty-show, stdenv, text |
3 | , thermoprint-bbcode, thermoprint-client, time | 3 | , thermoprint-bbcode, thermoprint-client, time |
4 | }: | 4 | }: |
5 | mkDerivation { | 5 | mkDerivation { |
@@ -9,8 +9,9 @@ mkDerivation { | |||
9 | isLibrary = false; | 9 | isLibrary = false; |
10 | isExecutable = true; | 10 | isExecutable = true; |
11 | executableHaskellDepends = [ | 11 | executableHaskellDepends = [ |
12 | aeson-pretty base bytestring containers optparse-applicative | 12 | aeson-pretty base bytestring containers exceptions |
13 | pretty-show text thermoprint-bbcode thermoprint-client time | 13 | optparse-applicative pretty-show text thermoprint-bbcode |
14 | thermoprint-client time | ||
14 | ]; | 15 | ]; |
15 | homepage = "http://dirty-haskell.org/tags/thermoprint.html"; | 16 | homepage = "http://dirty-haskell.org/tags/thermoprint.html"; |
16 | description = "A CLI for thermoprint-client"; | 17 | description = "A CLI for thermoprint-client"; |