aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGregor Kleen <gkleen@yggdrasil.li>2017-03-07 14:16:21 +0100
committerGregor Kleen <gkleen@yggdrasil.li>2017-03-07 14:16:21 +0100
commit7065a8cc1b8b01cd32d4b1d5317b323fec5238bd (patch)
treed6608f463b066aa6caf33357fd9ae0e508e49084
parent75d9fe614dca572aa1d7cfa53553e9c103eb2dd0 (diff)
downloadthermoprint-7065a8cc1b8b01cd32d4b1d5317b323fec5238bd.tar
thermoprint-7065a8cc1b8b01cd32d4b1d5317b323fec5238bd.tar.gz
thermoprint-7065a8cc1b8b01cd32d4b1d5317b323fec5238bd.tar.bz2
thermoprint-7065a8cc1b8b01cd32d4b1d5317b323fec5238bd.tar.xz
thermoprint-7065a8cc1b8b01cd32d4b1d5317b323fec5238bd.zip
Bump versions
-rw-r--r--client/src/Thermoprint/Client.hs55
-rw-r--r--client/thermoprint-client.cabal4
-rw-r--r--client/thermoprint-client.nix2
-rw-r--r--default.nix2
-rw-r--r--server/src/Thermoprint/Server/Push.hs2
-rw-r--r--server/thermoprint-server.cabal4
-rw-r--r--spec/src/Thermoprint/API.hs8
-rw-r--r--spec/src/Thermoprint/Identifiers.hs8
-rw-r--r--spec/thermoprint-spec.cabal6
-rw-r--r--spec/thermoprint-spec.nix2
-rw-r--r--tp-bbcode/thermoprint-bbcode.cabal8
-rw-r--r--tp-bbcode/thermoprint-bbcode.nix2
-rw-r--r--tprint/src/Options.hs24
-rw-r--r--tprint/src/Options/Utils.hs1
-rw-r--r--tprint/tprint.cabal8
-rw-r--r--tprint/tprint.nix2
-rw-r--r--webgui/src/Main.hs11
-rw-r--r--webgui/thermoprint-webgui.cabal6
-rw-r--r--webgui/thermoprint-webgui.nix2
19 files changed, 72 insertions, 85 deletions
diff --git a/client/src/Thermoprint/Client.hs b/client/src/Thermoprint/Client.hs
index 448a912..46f6073 100644
--- a/client/src/Thermoprint/Client.hs
+++ b/client/src/Thermoprint/Client.hs
@@ -5,12 +5,12 @@
5{-# LANGUAGE RecordWildCards #-} 5{-# LANGUAGE RecordWildCards #-}
6{-# LANGUAGE FlexibleContexts #-} 6{-# LANGUAGE FlexibleContexts #-}
7{-# LANGUAGE FlexibleInstances #-} 7{-# LANGUAGE FlexibleInstances #-}
8{-# LANGUAGE RankNTypes #-}
8 9
9-- | A client library for 'Thermoprint.API' 10-- | A client library for 'Thermoprint.API'
10module Thermoprint.Client 11module Thermoprint.Client
11 ( Client(..) 12 ( Client(..)
12 , mkClient, mkClient' 13 , mkClient, mkClient'
13 , throwNat, ioNat
14 -- = Reexports 14 -- = Reexports
15 , ServantError(..) 15 , ServantError(..)
16 , module Thermoprint.API 16 , module Thermoprint.API
@@ -27,10 +27,11 @@ import Data.Time (UTCTime)
27import Servant.Client hiding (HasClient(..)) 27import Servant.Client hiding (HasClient(..))
28import qualified Servant.Client as S 28import qualified Servant.Client as S
29import Servant.Common.BaseUrl 29import Servant.Common.BaseUrl
30import Servant.Common.Req
30import Network.HTTP.Client (Manager, ManagerSettings, newManager, defaultManagerSettings) 31import Network.HTTP.Client (Manager, ManagerSettings, newManager, defaultManagerSettings)
31import Servant.API 32import Servant.API
32import Servant.Utils.Enter 33import Servant.Utils.Enter
33import Control.Monad.Except (ExceptT, runExceptT) 34import Control.Monad.Except (ExceptT(..), runExceptT)
34 35
35import Control.Monad.Reader (ReaderT, runReaderT, ask) 36import Control.Monad.Reader (ReaderT, runReaderT, ask)
36import Control.Monad.Catch (Exception, MonadThrow(..)) 37import Control.Monad.Catch (Exception, MonadThrow(..))
@@ -92,29 +93,10 @@ withArgs subAPI = (\(a :<|> _) -> a) . subAPI :<|> (\(_ :<|> b) -> b) . subAPI
92 93
93mkClientS :: Monad m 94mkClientS :: Monad m
94 => (ClientM :~> m) -- ^ A monad functor ('Nat') used to make the api functions work in any monad which can do 'IO' and handle errors 95 => (ClientM :~> m) -- ^ A monad functor ('Nat') used to make the api functions work in any monad which can do 'IO' and handle errors
95 -> ManagerSettings
96 -> BaseUrl
97 -> Client m 96 -> Client m
98-- ^ Generate a 'Client' 97-- ^ Generate a 'Client'
99mkClientS n mgrS url = Client 98mkClientS n = Client{..}
100 { printers = clientF n printers
101 , jobs = \a b c -> clientF n $ jobs a b c
102 , jobCreate = \a b -> clientF n $ jobCreate a b
103 , job = \a -> clientF n $ job a
104 , jobStatus = \a -> clientF n $ jobStatus a
105 , jobDelete = \a -> clientF n $ jobDelete a
106 , drafts = clientF n drafts
107 , draftCreate = \a b -> clientF n $ draftCreate a b
108 , draftReplace = \a b c -> clientF n $ draftReplace a b c
109 , draft = \a -> clientF n $ draft a
110 , draftDelete = \a -> clientF n $ draftDelete a
111 , draftPrint = \a b -> clientF n $ draftPrint a b
112 }
113 where 99 where
114 clientF :: Monad m => (ClientM :~> m) -> (Manager -> BaseUrl -> m a) -> m a
115 clientF n f = do
116 mgr <- unNat n $ (liftIO $ newManager mgrS :: ClientM Manager)
117 f mgr url
118 printers 100 printers
119 :<|> (jobs :<|> jobCreate) 101 :<|> (jobs :<|> jobCreate)
120 :<|> (withArgs -> job :<|> (withArgs -> jobStatus :<|> jobDelete)) 102 :<|> (withArgs -> job :<|> (withArgs -> jobStatus :<|> jobDelete))
@@ -122,23 +104,14 @@ mkClientS n mgrS url = Client
122 :<|> (withArgs -> draftReplace :<|> (withArgs -> draft :<|> (withArgs -> draftDelete :<|> draftPrint))) 104 :<|> (withArgs -> draftReplace :<|> (withArgs -> draft :<|> (withArgs -> draftDelete :<|> draftPrint)))
123 = enter n $ client thermoprintAPI 105 = enter n $ client thermoprintAPI
124 106
125mkClient :: Monad m 107mkClient :: (MonadThrow m, MonadIO m) => ManagerSettings -> BaseUrl -> Client m
126 => (ClientM :~> m) -- ^ A monad functor ('Nat') used to make the api functions work in any monad which can do 'IO' and handle errors 108mkClient mSettings url = mkClientS $ Nat clientNat
127 -> BaseUrl 109 where
128 -> Client m 110 clientNat :: forall m a. (MonadThrow m, MonadIO m) => ClientM a -> m a
129mkClient n url = mkClientS n defaultManagerSettings url 111 clientNat cAct = do
130 112 mgr <- liftIO $ newManager mSettings
131mkClient' :: (MonadThrow m, MonadIO m) => BaseUrl -> Client m 113 either throwM return =<< liftIO (runClientM cAct $ ClientEnv mgr url)
132-- ^ @mkClient' = mkClient $ ioNat . throwNat@
133mkClient' = mkClient $ ioNat . throwNat
134
135throwNat :: (Exception e, MonadThrow m) => ExceptT e m :~> m
136-- ^ Squash a layer of 'EitherT' into the underlying monad supporting 'throwM'
137throwNat = Nat $ either throwM return <=< runExceptT
138
139ioNat :: MonadIO m => IO :~> m
140-- ^ @ioNat = Nat liftIO@
141ioNat = Nat liftIO
142 114
143readerNat :: a -> ReaderT a m :~> m 115mkClient' :: (MonadThrow m, MonadIO m) => BaseUrl -> Client m
144readerNat a = Nat $ flip runReaderT a 116-- ^ @mkClient' = mkClient defaultManagerSettings
117mkClient' = mkClient defaultManagerSettings
diff --git a/client/thermoprint-client.cabal b/client/thermoprint-client.cabal
index 0920773..1306542 100644
--- a/client/thermoprint-client.cabal
+++ b/client/thermoprint-client.cabal
@@ -2,7 +2,7 @@
2-- documentation, see http://haskell.org/cabal/users-guide/ 2-- documentation, see http://haskell.org/cabal/users-guide/
3 3
4name: thermoprint-client 4name: thermoprint-client
5version: 1.0.1 5version: 2.0.0
6synopsis: Client for thermoprint-spec 6synopsis: Client for thermoprint-spec
7-- description: 7-- description:
8homepage: http://dirty-haskell.org/tags/thermoprint.html 8homepage: http://dirty-haskell.org/tags/thermoprint.html
@@ -21,7 +21,7 @@ library
21 -- other-modules: 21 -- other-modules:
22 -- other-extensions: 22 -- other-extensions:
23 build-depends: base >=4.8 && <5 23 build-depends: base >=4.8 && <5
24 , thermoprint-spec ==5.0.* 24 , thermoprint-spec ==6.0.*
25 , servant >=0.4.4 && <1 25 , servant >=0.4.4 && <1
26 , servant-client >=0.4.4 && <1 26 , servant-client >=0.4.4 && <1
27 , servant-server >=0.4.4 && <1 27 , servant-server >=0.4.4 && <1
diff --git a/client/thermoprint-client.nix b/client/thermoprint-client.nix
index 8aadafb..7f83630 100644
--- a/client/thermoprint-client.nix
+++ b/client/thermoprint-client.nix
@@ -4,7 +4,7 @@
4}: 4}:
5mkDerivation { 5mkDerivation {
6 pname = "thermoprint-client"; 6 pname = "thermoprint-client";
7 version = "1.0.1"; 7 version = "2.0.0";
8 src = ./.; 8 src = ./.;
9 libraryHaskellDepends = [ 9 libraryHaskellDepends = [
10 base containers either exceptions http-client mtl servant 10 base containers either exceptions http-client mtl servant
diff --git a/default.nix b/default.nix
index 09e2b7b..f883c52 100644
--- a/default.nix
+++ b/default.nix
@@ -7,6 +7,8 @@ rec {
7 overrides = self: super: with super; { 7 overrides = self: super: with super; {
8 # threepenny-gui = pkgs.haskell.lib.appendPatch threepenny-gui ./threepenny.patch; 8 # threepenny-gui = pkgs.haskell.lib.appendPatch threepenny-gui ./threepenny.patch;
9 encoding = pkgs.haskell.lib.doJailbreak encoding; 9 encoding = pkgs.haskell.lib.doJailbreak encoding;
10 cabal-test-quickcheck = pkgs.haskell.lib.doJailbreak cabal-test-quickcheck;
11 extended-reals = pkgs.haskell.lib.doJailbreak extended-reals;
10 }; 12 };
11 }; 13 };
12 thermoprint-spec = haskellPackages.callPackage ./spec/thermoprint-spec.nix {}; 14 thermoprint-spec = haskellPackages.callPackage ./spec/thermoprint-spec.nix {};
diff --git a/server/src/Thermoprint/Server/Push.hs b/server/src/Thermoprint/Server/Push.hs
index 07b81fb..7ae03a6 100644
--- a/server/src/Thermoprint/Server/Push.hs
+++ b/server/src/Thermoprint/Server/Push.hs
@@ -32,7 +32,7 @@ import qualified Data.Text as Text
32type Notification = URI 32type Notification = URI
33 33
34withPush :: TChan Notification -> Application -> Application 34withPush :: TChan Notification -> Application -> Application
35withPush chan = websocketsOr defaultConnectionOptions $ flip acceptRequestWith (AcceptRequest $ Just protocolSpec) >=> handleClient chan 35withPush chan = websocketsOr defaultConnectionOptions $ flip acceptRequestWith (AcceptRequest (Just protocolSpec) []) >=> handleClient chan
36 36
37protocolSpec :: ByteString 37protocolSpec :: ByteString
38protocolSpec = CBS.pack $ "thermoprint-server.notification." ++ showVersion version 38protocolSpec = CBS.pack $ "thermoprint-server.notification." ++ showVersion version
diff --git a/server/thermoprint-server.cabal b/server/thermoprint-server.cabal
index eae3754..1ed55a6 100644
--- a/server/thermoprint-server.cabal
+++ b/server/thermoprint-server.cabal
@@ -50,7 +50,7 @@ library
50 , servant-server >=0.4.4 && <1 50 , servant-server >=0.4.4 && <1
51 , stm >=2.4.4 && <3 51 , stm >=2.4.4 && <3
52 , text >=1.2.1 && <2 52 , text >=1.2.1 && <2
53 , thermoprint-spec ==5.0.* 53 , thermoprint-spec ==6.0.*
54 , time >=1.5.0 && <2 54 , time >=1.5.0 && <2
55 , wai >=3.0.4 && <4 55 , wai >=3.0.4 && <4
56 , warp >=3.1.9 && <4 56 , warp >=3.1.9 && <4
@@ -76,7 +76,7 @@ Test-Suite tests
76 main-is: Spec.hs 76 main-is: Spec.hs
77 build-depends: base >=4.8.1 && <5 77 build-depends: base >=4.8.1 && <5
78 , thermoprint-server ==2.0.* 78 , thermoprint-server ==2.0.*
79 , thermoprint-client ==1.0.* 79 , thermoprint-client ==2.0.*
80 , thermoprint-spec -any 80 , thermoprint-spec -any
81 , hspec >=2.2.1 && <3 81 , hspec >=2.2.1 && <3
82 , QuickCheck >=2.8.1 && <3 82 , QuickCheck >=2.8.1 && <3
diff --git a/spec/src/Thermoprint/API.hs b/spec/src/Thermoprint/API.hs
index 8e98db8..5b24e54 100644
--- a/spec/src/Thermoprint/API.hs
+++ b/spec/src/Thermoprint/API.hs
@@ -55,11 +55,11 @@ import Test.QuickCheck.Arbitrary (Arbitrary(..), CoArbitrary(..))
55import Test.QuickCheck.Gen (scale, variant, oneof) 55import Test.QuickCheck.Gen (scale, variant, oneof)
56import Test.QuickCheck.Instances 56import Test.QuickCheck.Instances
57 57
58instance (Integral k, Ord k, ToJSON v) => ToJSON (Map k v) where 58-- instance (Integral k, Ord k, ToJSON v) => ToJSON (Map k v) where
59 toJSON = toJSON . Map.foldMapWithKey (IntMap.singleton . castId) 59-- toJSON = toJSON . Map.foldMapWithKey (IntMap.singleton . castId)
60 60
61instance (Enum k, Ord k, FromJSON v) => FromJSON (Map k v) where 61-- instance (Enum k, Ord k, FromJSON v) => FromJSON (Map k v) where
62 parseJSON = fmap (IntMap.foldMapWithKey $ Map.singleton . castId) . parseJSON 62-- parseJSON = fmap (IntMap.foldMapWithKey $ Map.singleton . castId) . parseJSON
63 63
64data PrinterStatus = Busy JobId 64data PrinterStatus = Busy JobId
65 | Available 65 | Available
diff --git a/spec/src/Thermoprint/Identifiers.hs b/spec/src/Thermoprint/Identifiers.hs
index 2a07318..e90602c 100644
--- a/spec/src/Thermoprint/Identifiers.hs
+++ b/spec/src/Thermoprint/Identifiers.hs
@@ -13,16 +13,16 @@ import GHC.Generics (Generic)
13import Control.DeepSeq (NFData) 13import Control.DeepSeq (NFData)
14 14
15import Servant.API (ToHttpApiData, FromHttpApiData) 15import Servant.API (ToHttpApiData, FromHttpApiData)
16import Data.Aeson (FromJSON, ToJSON) 16import Data.Aeson (FromJSON, ToJSON, FromJSONKey, ToJSONKey)
17 17
18newtype PrinterId = PrinterId Integer 18newtype PrinterId = PrinterId Integer
19 deriving (Show, Read, Eq, Ord, Num, Real, Integral, Enum, FromHttpApiData, ToHttpApiData, FromJSON, ToJSON, Typeable, Generic, NFData) 19 deriving (Show, Read, Eq, Ord, Num, Real, Integral, Enum, FromHttpApiData, ToHttpApiData, FromJSON, ToJSON, ToJSONKey, FromJSONKey, Typeable, Generic, NFData)
20 20
21newtype JobId = JobId Integer 21newtype JobId = JobId Integer
22 deriving (Show, Read, Eq, Ord, Num, Real, Integral, Enum, FromHttpApiData, ToHttpApiData, FromJSON, ToJSON, Typeable, Generic, NFData) 22 deriving (Show, Read, Eq, Ord, Num, Real, Integral, Enum, FromHttpApiData, ToHttpApiData, FromJSON, ToJSON, ToJSONKey, FromJSONKey, Typeable, Generic, NFData)
23 23
24newtype DraftId = DraftId Integer 24newtype DraftId = DraftId Integer
25 deriving (Show, Read, Eq, Ord, Num, Real, Integral, Enum, FromHttpApiData, ToHttpApiData, FromJSON, ToJSON, Typeable, Generic, NFData) 25 deriving (Show, Read, Eq, Ord, Num, Real, Integral, Enum, FromHttpApiData, ToHttpApiData, FromJSON, ToJSON, ToJSONKey, FromJSONKey, Typeable, Generic, NFData)
26 26
27castId :: (Integral a, Enum b) => a -> b 27castId :: (Integral a, Enum b) => a -> b
28castId = toEnum . fromInteger . toInteger 28castId = toEnum . fromInteger . toInteger
diff --git a/spec/thermoprint-spec.cabal b/spec/thermoprint-spec.cabal
index 138a06e..4bcfe6a 100644
--- a/spec/thermoprint-spec.cabal
+++ b/spec/thermoprint-spec.cabal
@@ -2,7 +2,7 @@
2-- documentation, see http://haskell.org/cabal/users-guide/ 2-- documentation, see http://haskell.org/cabal/users-guide/
3 3
4name: thermoprint-spec 4name: thermoprint-spec
5version: 5.0.1 5version: 6.0.0
6synopsis: A specification of the API and the payload datatypes and associated utilities 6synopsis: A specification of the API and the payload datatypes and associated utilities
7-- description: 7-- description:
8homepage: http://dirty-haskell.org/tags/thermoprint.html 8homepage: http://dirty-haskell.org/tags/thermoprint.html
@@ -41,7 +41,7 @@ library
41 , Cabal >=1.22.4 && <2 41 , Cabal >=1.22.4 && <2
42 , cabal-test-quickcheck >=0.1.6 && <1 42 , cabal-test-quickcheck >=0.1.6 && <1
43 , servant >=0.4.4 && <1 43 , servant >=0.4.4 && <1
44 , aeson >=0.9.0 && <1 44 , aeson >=1.0 && <2
45 , base64-bytestring >=1.0.0 && <2 45 , base64-bytestring >=1.0.0 && <2
46 , encoding >=0.8 && <1 46 , encoding >=0.8 && <1
47 , time >=1.5.0 && <2 47 , time >=1.5.0 && <2
@@ -62,4 +62,4 @@ Test-Suite tests
62 , hspec >=2.2.1 && <3 62 , hspec >=2.2.1 && <3
63 , QuickCheck >=2.8.1 && <3 63 , QuickCheck >=2.8.1 && <3
64 , quickcheck-instances >=0.3.11 && <4 64 , quickcheck-instances >=0.3.11 && <4
65 , aeson >=0.9.0 && <1 \ No newline at end of file 65 , aeson >=1.0 && <2 \ No newline at end of file
diff --git a/spec/thermoprint-spec.nix b/spec/thermoprint-spec.nix
index a3093de..d28b405 100644
--- a/spec/thermoprint-spec.nix
+++ b/spec/thermoprint-spec.nix
@@ -4,7 +4,7 @@
4}: 4}:
5mkDerivation { 5mkDerivation {
6 pname = "thermoprint-spec"; 6 pname = "thermoprint-spec";
7 version = "5.0.1"; 7 version = "6.0.0";
8 src = ./.; 8 src = ./.;
9 libraryHaskellDepends = [ 9 libraryHaskellDepends = [
10 aeson base base64-bytestring bytestring Cabal cabal-test-quickcheck 10 aeson base base64-bytestring bytestring Cabal cabal-test-quickcheck
diff --git a/tp-bbcode/thermoprint-bbcode.cabal b/tp-bbcode/thermoprint-bbcode.cabal
index 89ed326..9fdf216 100644
--- a/tp-bbcode/thermoprint-bbcode.cabal
+++ b/tp-bbcode/thermoprint-bbcode.cabal
@@ -2,7 +2,7 @@
2-- documentation, see http://haskell.org/cabal/users-guide/ 2-- documentation, see http://haskell.org/cabal/users-guide/
3 3
4name: thermoprint-bbcode 4name: thermoprint-bbcode
5version: 2.0.1 5version: 3.0.0
6synopsis: Parse bbcode for use in thermoprint 6synopsis: Parse bbcode for use in thermoprint
7-- description: 7-- description:
8homepage: http://dirty-haskell.org/tags/thermoprint.html 8homepage: http://dirty-haskell.org/tags/thermoprint.html
@@ -24,7 +24,7 @@ library
24 , OverloadedLists 24 , OverloadedLists
25 -- other-extensions: 25 -- other-extensions:
26 build-depends: base >=4.8.1 && <5 26 build-depends: base >=4.8.1 && <5
27 , thermoprint-spec ==5.0.* 27 , thermoprint-spec ==6.0.*
28 , bbcode >=3.1.1 && <4 28 , bbcode >=3.1.1 && <4
29 , containers -any 29 , containers -any
30 , text -any 30 , text -any
@@ -44,10 +44,10 @@ Test-Suite tests
44 , OverloadedLists 44 , OverloadedLists
45 build-depends: base >=4.8.1 && <5 45 build-depends: base >=4.8.1 && <5
46 , thermoprint-bbcode -any 46 , thermoprint-bbcode -any
47 , thermoprint-spec ==5.0.* 47 , thermoprint-spec ==6.0.*
48 , hspec >=2.2.1 && <3 48 , hspec >=2.2.1 && <3
49 , QuickCheck >=2.8.1 && <3 49 , QuickCheck >=2.8.1 && <3
50 , quickcheck-instances >=0.3.11 && <4 50 , quickcheck-instances >=0.3.11 && <4
51 , aeson >=0.9.0 && <1 51 , aeson >=1.0 && <2
52 , containers -any 52 , containers -any
53 , text -any \ No newline at end of file 53 , text -any \ No newline at end of file
diff --git a/tp-bbcode/thermoprint-bbcode.nix b/tp-bbcode/thermoprint-bbcode.nix
index 3c698f1..deab20e 100644
--- a/tp-bbcode/thermoprint-bbcode.nix
+++ b/tp-bbcode/thermoprint-bbcode.nix
@@ -4,7 +4,7 @@
4}: 4}:
5mkDerivation { 5mkDerivation {
6 pname = "thermoprint-bbcode"; 6 pname = "thermoprint-bbcode";
7 version = "2.0.1"; 7 version = "3.0.0";
8 src = ./.; 8 src = ./.;
9 libraryHaskellDepends = [ 9 libraryHaskellDepends = [
10 base bbcode bytestring case-insensitive containers text 10 base bbcode bytestring case-insensitive containers text
diff --git a/tprint/src/Options.hs b/tprint/src/Options.hs
index e146f91..703c23b 100644
--- a/tprint/src/Options.hs
+++ b/tprint/src/Options.hs
@@ -26,8 +26,12 @@ import Instances ()
26import Paths_tprint (version) 26import Paths_tprint (version)
27import Data.Version (showVersion) 27import Data.Version (showVersion)
28 28
29import Data.Maybe
30import Data.Monoid
29import Data.Bifunctor (Bifunctor(..)) 31import Data.Bifunctor (Bifunctor(..))
30 32
33import System.Environment (lookupEnv)
34
31data TPrint = TPrint 35data TPrint = TPrint
32 { baseUrl :: BaseUrl 36 { baseUrl :: BaseUrl
33 , dryRun :: Bool 37 , dryRun :: Bool
@@ -149,12 +153,15 @@ pOperation = hsubparser $ mconcat [ command "printers" cmdPrinters
149 ) (progDesc "Interact with drafts") 153 ) (progDesc "Interact with drafts")
150 ] 154 ]
151 155
152pTPrint :: Parser TPrint 156pTPrint :: IO (Parser TPrint)
153pTPrint = TPrint <$> option (eitherReader $ first show . parseBaseUrl) (metavar "URL" <> long "baseurl" <> short 'u' <> help "Server to interact with" <> value (BaseUrl Http "localhost" 3000 "") <> showDefaultWith showBaseUrl) 157pTPrint = do
154 <*> switch (long "dry-run" <> short 'n' <> help "Don't send any requests that would be expected to change the servers state") 158 baseUrl <- parseBaseUrl =<< (fromMaybe "http://localhost:3000/" <$> lookupEnv "TPRINT_BASEURL")
155 <*> pOutput 159 return $
156 <*> pOperation 160 TPrint <$> option (eitherReader $ first show . parseBaseUrl) (metavar "URL" <> long "baseurl" <> short 'u' <> help "Server to interact with; also read from TPRINT_BASEURL when set" <> value baseUrl <> showDefaultWith showBaseUrl)
157 <*> switch (long "dump-options" <> internal) 161 <*> switch (long "dry-run" <> short 'n' <> help "Don't send any requests that would be expected to change the servers state")
162 <*> pOutput
163 <*> pOperation
164 <*> switch (long "dump-options" <> internal)
158 165
159pOutput :: Parser Output 166pOutput :: Parser Output
160pOutput = (,) <$> pOutputFormat <*> pSink 167pOutput = (,) <$> pOutputFormat <*> pSink
@@ -177,4 +184,7 @@ pInput = (,) <$> pInputFormat <*> pSource
177 rSource' x = ReadFile x 184 rSource' x = ReadFile x
178 185
179withArgs :: (TPrint -> IO a) -> IO a 186withArgs :: (TPrint -> IO a) -> IO a
180withArgs a = customExecParser (prefs $ showHelpOnError) (info pTPrint $ header ("tprint " ++ showVersion version) <> progDesc "A cli for Thermoprint.Client") >>= a 187withArgs a = do
188 pTPrint' <- pTPrint
189 customExecParser (prefs $ showHelpOnError) (info pTPrint' $ header ("tprint " ++ showVersion version) <> progDesc "A cli for Thermoprint.Client") >>= a
190
diff --git a/tprint/src/Options/Utils.hs b/tprint/src/Options/Utils.hs
index 237aa56..3fae250 100644
--- a/tprint/src/Options/Utils.hs
+++ b/tprint/src/Options/Utils.hs
@@ -13,6 +13,7 @@ import Options.Applicative
13import Data.Text (Text) 13import Data.Text (Text)
14import qualified Data.Text as T (pack) 14import qualified Data.Text as T (pack)
15 15
16import Data.Monoid
16import Data.Char 17import Data.Char
17import Data.Maybe 18import Data.Maybe
18import Data.List 19import Data.List
diff --git a/tprint/tprint.cabal b/tprint/tprint.cabal
index 5fcd00b..94b0a8a 100644
--- a/tprint/tprint.cabal
+++ b/tprint/tprint.cabal
@@ -2,7 +2,7 @@
2-- documentation, see http://haskell.org/cabal/users-guide/ 2-- documentation, see http://haskell.org/cabal/users-guide/
3 3
4name: tprint 4name: tprint
5version: 2.0.0 5version: 3.0.0
6synopsis: A CLI for thermoprint-client 6synopsis: A CLI for thermoprint-client
7-- description: 7-- description:
8homepage: http://dirty-haskell.org/tags/thermoprint.html 8homepage: http://dirty-haskell.org/tags/thermoprint.html
@@ -23,15 +23,15 @@ executable tprint
23 , Instances 23 , Instances
24 -- other-extensions: 24 -- other-extensions:
25 build-depends: base >=4.8 && <5 25 build-depends: base >=4.8 && <5
26 , thermoprint-bbcode >=2.0.0 && <3 26 , thermoprint-bbcode >=3.0.0 && <4
27 , thermoprint-client ==1.0.* 27 , thermoprint-client ==2.0.*
28 , optparse-applicative >=0.12.1 && <1 28 , optparse-applicative >=0.12.1 && <1
29 , containers >=0.5.6 && <1 29 , containers >=0.5.6 && <1
30 , time >=1.5.0 && <2 30 , time >=1.5.0 && <2
31 , pretty-show >=1.6.9 && <2 31 , pretty-show >=1.6.9 && <2
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 , aeson >=0.9.0 && <1 34 , aeson >=1.0 && <2
35 , bytestring >=0.10.6 && <1 35 , bytestring >=0.10.6 && <1
36 , exceptions >=0.8.2 && <1 36 , exceptions >=0.8.2 && <1
37 , deepseq >=1.4.1 && <2 37 , deepseq >=1.4.1 && <2
diff --git a/tprint/tprint.nix b/tprint/tprint.nix
index 946a4ce..9ce247d 100644
--- a/tprint/tprint.nix
+++ b/tprint/tprint.nix
@@ -4,7 +4,7 @@
4}: 4}:
5mkDerivation { 5mkDerivation {
6 pname = "tprint"; 6 pname = "tprint";
7 version = "2.0.0"; 7 version = "3.0.0";
8 src = ./.; 8 src = ./.;
9 isLibrary = false; 9 isLibrary = false;
10 isExecutable = true; 10 isExecutable = true;
diff --git a/webgui/src/Main.hs b/webgui/src/Main.hs
index 03cd318..65dbfc7 100644
--- a/webgui/src/Main.hs
+++ b/webgui/src/Main.hs
@@ -40,6 +40,7 @@ import Data.Time
40import Control.Concurrent 40import Control.Concurrent
41import Control.Exception 41import Control.Exception
42import Control.Monad.Catch 42import Control.Monad.Catch
43import Control.Monad.Catch.Pure
43 44
44import Control.Applicative 45import Control.Applicative
45import Control.Monad hiding (sequence) 46import Control.Monad hiding (sequence)
@@ -151,9 +152,9 @@ setup Config{..} window (split -> (socketErr, dataUpdate)) = void $ do
151 status <- stepper init statusEvent 152 status <- stepper init statusEvent
152 return (status, triggerStatusChange) 153 return (status, triggerStatusChange)
153 154
154 Client{..} = mkClient (hoistNat $ Nat liftIO) server 155 Client{..} = (mkClient' server :: Client (CatchT UI))
155 withFatal :: ExceptT ServantError UI a -> UI a 156 withFatal :: CatchT UI a -> UI a
156 withFatal a = either (fatal . ("Error while communicating to Thermoprint.Server: " ++) . show) return =<< runExceptT a 157 withFatal a = either (fatal . ("Error while communicating to Thermoprint.Server: " ++) . show) return =<< runCatchT a
157 158
158 handleEditor selectedPrinter (_, modifyFocusedJobs) = do 159 handleEditor selectedPrinter (_, modifyFocusedJobs) = do
159 title <- fatal' "Could not find editor title field" =<< getElementById window "editorTitle" 160 title <- fatal' "Could not find editor title field" =<< getElementById window "editorTitle"
@@ -259,7 +260,7 @@ setup Config{..} window (split -> (socketErr, dataUpdate)) = void $ do
259 enactDeletion <- fatal' "Could not find deletion button" =<< getElementById window "enactDeletion" 260 enactDeletion <- fatal' "Could not find deletion button" =<< getElementById window "enactDeletion"
260 on UI.click enactDeletion . const $ do 261 on UI.click enactDeletion . const $ do
261 cMarking <- currentValue marking 262 cMarking <- currentValue marking
262 mapM_ (runExceptT . draftDelete) cMarking 263 mapM_ (runCatchT . draftDelete) cMarking
263 cDraft <- associatedDraft <$> currentValue editorState 264 cDraft <- associatedDraft <$> currentValue editorState
264 when (Set.member cDraft $ Set.map Just cMarking) $ changeEditorState (\s -> s { associatedDraft = Nothing } ) 265 when (Set.member cDraft $ Set.map Just cMarking) $ changeEditorState (\s -> s { associatedDraft = Nothing } )
265 updateMarking Set.empty 266 updateMarking Set.empty
@@ -348,7 +349,7 @@ setup Config{..} window (split -> (socketErr, dataUpdate)) = void $ do
348 (marking, (liftIO .) -> updateMarking) <- stepper' $ Set.empty 349 (marking, (liftIO .) -> updateMarking) <- stepper' $ Set.empty
349 350
350 enactAbortion <- fatal' "Could not find deletion button" =<< getElementById window "enactAbortion" 351 enactAbortion <- fatal' "Could not find deletion button" =<< getElementById window "enactAbortion"
351 on UI.click enactAbortion . const $ currentValue marking >>= mapM_ (runExceptT . jobDelete) >> updateMarking Set.empty 352 on UI.click enactAbortion . const $ currentValue marking >>= mapM_ (runCatchT . jobDelete) >> updateMarking Set.empty
352 353
353 (selectedPrinter, updatePrinter) <- do 354 (selectedPrinter, updatePrinter) <- do
354 autoselectPrinter <- fatal' "Could not find printer autoselect switch" =<< getElementById window "autoselectPrinter" 355 autoselectPrinter <- fatal' "Could not find printer autoselect switch" =<< getElementById window "autoselectPrinter"
diff --git a/webgui/thermoprint-webgui.cabal b/webgui/thermoprint-webgui.cabal
index 9c67a9c..dcd3c4f 100644
--- a/webgui/thermoprint-webgui.cabal
+++ b/webgui/thermoprint-webgui.cabal
@@ -2,7 +2,7 @@
2-- documentation, see http://haskell.org/cabal/users-guide/ 2-- documentation, see http://haskell.org/cabal/users-guide/
3 3
4name: thermoprint-webgui 4name: thermoprint-webgui
5version: 1.0.2 5version: 2.0.0
6synopsis: Threepenny interface for thermoprint-spec compliant servers 6synopsis: Threepenny interface for thermoprint-spec compliant servers
7-- description: 7-- description:
8homepage: http://dirty-haskell.org/tags/thermoprint.html 8homepage: http://dirty-haskell.org/tags/thermoprint.html
@@ -26,8 +26,8 @@ executable thermoprint-webgui
26 -- other-modules: 26 -- other-modules:
27 -- other-extensions: 27 -- other-extensions:
28 build-depends: base >=4.8 && <5 28 build-depends: base >=4.8 && <5
29 , thermoprint-bbcode >=2.0.0 && <3 29 , thermoprint-bbcode >=3.0.0 && <4
30 , thermoprint-client ==1.0.* 30 , thermoprint-client ==2.0.*
31 , threepenny-gui >=0.6.0 && <1 31 , threepenny-gui >=0.6.0 && <1
32 , optparse-applicative >=0.12.1 && <1 32 , optparse-applicative >=0.12.1 && <1
33 , bytestring >=0.10.6 && <1 33 , bytestring >=0.10.6 && <1
diff --git a/webgui/thermoprint-webgui.nix b/webgui/thermoprint-webgui.nix
index d4cafe8..bff836e 100644
--- a/webgui/thermoprint-webgui.nix
+++ b/webgui/thermoprint-webgui.nix
@@ -5,7 +5,7 @@
5}: 5}:
6mkDerivation { 6mkDerivation {
7 pname = "thermoprint-webgui"; 7 pname = "thermoprint-webgui";
8 version = "1.0.2"; 8 version = "2.0.0";
9 src = ./.; 9 src = ./.;
10 isLibrary = false; 10 isLibrary = false;
11 isExecutable = true; 11 isExecutable = true;