aboutsummaryrefslogtreecommitdiff
path: root/tprint
diff options
context:
space:
mode:
authorGregor Kleen <gkleen@yggdrasil.li>2016-03-01 10:34:06 +0100
committerGregor Kleen <gkleen@yggdrasil.li>2016-03-01 10:34:06 +0100
commit1774f95a5c658cea2850e54c7cb164f4ad62e58d (patch)
treec95940daecc9fa74e5a5cf53e68b7680150db8c2 /tprint
parentf52ec2c8694b2e0ec4bce4c533cb930b68adf00b (diff)
downloadthermoprint-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.hs9
-rw-r--r--tprint/tprint.cabal1
-rw-r--r--tprint/tprint.nix7
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)
7import qualified Data.Sequence as Seq 7import qualified Data.Sequence as Seq
8import Data.Text (Text) 8import Data.Text (Text)
9import qualified Data.Text as T 9import qualified Data.Text as T
10import qualified Data.Text.IO as T
10import qualified Data.ByteString.Lazy.Char8 as Lazy (ByteString) 11import qualified Data.ByteString.Lazy.Char8 as Lazy (ByteString)
11import qualified Data.ByteString.Lazy.Char8 as LCBS 12import qualified Data.ByteString.Lazy.Char8 as LCBS
12import Data.Time 13import Data.Time
@@ -15,14 +16,17 @@ import Data.Foldable
15import Data.List 16import Data.List
16import Data.Monoid 17import Data.Monoid
17import Data.Maybe 18import Data.Maybe
19import Data.Either
18 20
19import Control.Monad 21import Control.Monad
22import Control.Monad.Catch
20 23
21import Text.Show.Pretty (dumpStr) 24import Text.Show.Pretty (dumpStr)
22import Data.Aeson.Encode.Pretty (encodePretty) 25import Data.Aeson.Encode.Pretty (encodePretty)
23 26
24import System.IO 27import System.IO
25 28
29import Thermoprint.Printout.BBCode
26import Thermoprint.Client 30import Thermoprint.Client
27import Options 31import 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
75tprint 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
72tprint _ _ _ = undefined 81tprint _ _ _ = 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}:
5mkDerivation { 5mkDerivation {
@@ -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";