From 7065a8cc1b8b01cd32d4b1d5317b323fec5238bd Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Tue, 7 Mar 2017 14:16:21 +0100 Subject: Bump versions --- tprint/src/Options.hs | 24 +++++++++++++++++------- tprint/src/Options/Utils.hs | 1 + tprint/tprint.cabal | 8 ++++---- tprint/tprint.nix | 2 +- 4 files changed, 23 insertions(+), 12 deletions(-) (limited to 'tprint') 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 () import Paths_tprint (version) import Data.Version (showVersion) +import Data.Maybe +import Data.Monoid import Data.Bifunctor (Bifunctor(..)) +import System.Environment (lookupEnv) + data TPrint = TPrint { baseUrl :: BaseUrl , dryRun :: Bool @@ -149,12 +153,15 @@ pOperation = hsubparser $ mconcat [ command "printers" cmdPrinters ) (progDesc "Interact with drafts") ] -pTPrint :: Parser TPrint -pTPrint = TPrint <$> option (eitherReader $ first show . parseBaseUrl) (metavar "URL" <> long "baseurl" <> short 'u' <> help "Server to interact with" <> value (BaseUrl Http "localhost" 3000 "") <> showDefaultWith showBaseUrl) - <*> switch (long "dry-run" <> short 'n' <> help "Don't send any requests that would be expected to change the servers state") - <*> pOutput - <*> pOperation - <*> switch (long "dump-options" <> internal) +pTPrint :: IO (Parser TPrint) +pTPrint = do + baseUrl <- parseBaseUrl =<< (fromMaybe "http://localhost:3000/" <$> lookupEnv "TPRINT_BASEURL") + return $ + 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) + <*> switch (long "dry-run" <> short 'n' <> help "Don't send any requests that would be expected to change the servers state") + <*> pOutput + <*> pOperation + <*> switch (long "dump-options" <> internal) pOutput :: Parser Output pOutput = (,) <$> pOutputFormat <*> pSink @@ -177,4 +184,7 @@ pInput = (,) <$> pInputFormat <*> pSource rSource' x = ReadFile x withArgs :: (TPrint -> IO a) -> IO a -withArgs a = customExecParser (prefs $ showHelpOnError) (info pTPrint $ header ("tprint " ++ showVersion version) <> progDesc "A cli for Thermoprint.Client") >>= a +withArgs a = do + pTPrint' <- pTPrint + customExecParser (prefs $ showHelpOnError) (info pTPrint' $ header ("tprint " ++ showVersion version) <> progDesc "A cli for Thermoprint.Client") >>= a + 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 import Data.Text (Text) import qualified Data.Text as T (pack) +import Data.Monoid import Data.Char import Data.Maybe import 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 @@ -- documentation, see http://haskell.org/cabal/users-guide/ name: tprint -version: 2.0.0 +version: 3.0.0 synopsis: A CLI for thermoprint-client -- description: homepage: http://dirty-haskell.org/tags/thermoprint.html @@ -23,15 +23,15 @@ executable tprint , Instances -- other-extensions: build-depends: base >=4.8 && <5 - , thermoprint-bbcode >=2.0.0 && <3 - , thermoprint-client ==1.0.* + , thermoprint-bbcode >=3.0.0 && <4 + , thermoprint-client ==2.0.* , optparse-applicative >=0.12.1 && <1 , containers >=0.5.6 && <1 , time >=1.5.0 && <2 , pretty-show >=1.6.9 && <2 , text >=1.2.2 && <2 , aeson-pretty >=0.7.2 && <1 - , aeson >=0.9.0 && <1 + , aeson >=1.0 && <2 , bytestring >=0.10.6 && <1 , exceptions >=0.8.2 && <1 , 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 @@ }: mkDerivation { pname = "tprint"; - version = "2.0.0"; + version = "3.0.0"; src = ./.; isLibrary = false; isExecutable = true; -- cgit v1.2.3