aboutsummaryrefslogtreecommitdiff
path: root/tprint
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 /tprint
parent75d9fe614dca572aa1d7cfa53553e9c103eb2dd0 (diff)
downloadthermoprint-7065a8cc1b8b01cd32d4b1d5317b323fec5238bd.tar
thermoprint-7065a8cc1b8b01cd32d4b1d5317b323fec5238bd.tar.gz
thermoprint-7065a8cc1b8b01cd32d4b1d5317b323fec5238bd.tar.bz2
thermoprint-7065a8cc1b8b01cd32d4b1d5317b323fec5238bd.tar.xz
thermoprint-7065a8cc1b8b01cd32d4b1d5317b323fec5238bd.zip
Bump versions
Diffstat (limited to 'tprint')
-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
4 files changed, 23 insertions, 12 deletions
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;