configuration-tools 0.6.1 → 0.7.0
raw patch · 13 files changed
+65/−144 lines, 13 filesdep +crypton-connectiondep +crypton-x509dep +crypton-x509-systemdep −ansi-wl-pprintdep −connectiondep −x509dep ~Cabaldep ~basedep ~http-clientsetup-changedPVP ok
version bump matches the API change (PVP)
Dependencies added: crypton-connection, crypton-x509, crypton-x509-system, crypton-x509-validation, prettyprinter
Dependencies removed: ansi-wl-pprint, connection, x509, x509-system, x509-validation
Dependency ranges changed: Cabal, base, http-client, http-client-tls, optparse-applicative, wai, warp, warp-tls
API changes (from Hackage documentation)
+ Configuration.Utils.CommandLine: [helpDescription] :: ParserHelp -> Chunk Doc
+ Configuration.Utils.CommandLine: [prefTabulateFill] :: ParserPrefs -> Int
+ Configuration.Utils.CommandLine: asum :: (Foldable t, Alternative f) => t (f a) -> f a
+ Configuration.Utils.CommandLine: helpIndent :: Int -> PrefsMod
+ Configuration.Utils.CommandLine: simpleVersioner :: String -> Parser (a -> a)
- Configuration.Utils.CommandLine: ParserHelp :: Chunk Doc -> Chunk Doc -> Chunk Doc -> Chunk Doc -> Chunk Doc -> Chunk Doc -> Chunk Doc -> ParserHelp
+ Configuration.Utils.CommandLine: ParserHelp :: Chunk Doc -> Chunk Doc -> Chunk Doc -> Chunk Doc -> Chunk Doc -> Chunk Doc -> Chunk Doc -> Chunk Doc -> ParserHelp
- Configuration.Utils.CommandLine: ParserPrefs :: String -> Bool -> Bool -> Bool -> Backtracking -> Int -> Bool -> Bool -> ParserPrefs
+ Configuration.Utils.CommandLine: ParserPrefs :: String -> Bool -> Bool -> Bool -> Backtracking -> Int -> Bool -> Bool -> Int -> ParserPrefs
Files
- CHANGELOG.md +13/−0
- Setup.hs +3/−27
- configuration-tools.cabal +33/−31
- examples/Example.hs +0/−4
- src/Configuration/Utils.hs +16/−20
- src/Configuration/Utils/CommandLine.hs +0/−5
- src/Configuration/Utils/Http.hs +0/−4
- src/Configuration/Utils/Internal/HttpsCertPolicy.hs +0/−18
- src/Configuration/Utils/Monoid.hs +0/−2
- src/Configuration/Utils/Setup.hs +0/−21
- test/TestExample.hs +0/−4
- test/TestTools.hs +0/−4
- test/Tests/MonoidConfig.hs +0/−4
CHANGELOG.md view
@@ -1,5 +1,18 @@ # configuration-tools +## 0.7.0 (2022-06-22)++The version bump is due to the update of the dependency on optparse-applicative,+which could imply breaking changes for users.++* Support GHC-9.6.+* Require Cabal >=3.6.+* Drop support for GHC <8.10.+* Require optparse-applicative >=0.18.+* Require prettyprinter package and drop dependency on deprecated ansi-wl-pprint.+* Replace dependency on cryptonite package by crypton.+* Raise some outdated lower dependency bounds.+ ## 0.6.1 (2021-10-12) * Support GHC-9.2
Setup.hs view
@@ -111,15 +111,8 @@ import Distribution.Simple.PackageIndex import Distribution.Simple.Setup import Distribution.Text-import Distribution.Types.UnqualComponentName--#if MIN_VERSION_Cabal(3,6,0) import Distribution.Utils.Path-#endif--#if MIN_VERSION_Cabal(3,2,0) import Distribution.Utils.ShortText-#endif import System.Process @@ -169,14 +162,6 @@ prettyLicense :: I.InstalledPackageInfo -> String prettyLicense = either prettyShow prettyShow . I.license -#if MIN_VERSION_Cabal(3,2,0)-ft :: ShortText -> String-ft = fromShortText-#else-ft :: String -> String-ft = id-#endif- -- -------------------------------------------------------------------------- -- -- Cabal 2.0 @@ -238,11 +223,7 @@ trim = f . f where f = reverse . dropWhile isSpace -#if defined (MIN_VERSION_Cabal) && MIN_VERSION_Cabal(3,4,0) getVCS :: IO (Maybe KnownRepoType)-#else-getVCS :: IO (Maybe RepoType)-#endif getVCS = getCurrentDirectory >>= getVcsOfDir where getVcsOfDir d = do@@ -318,10 +299,10 @@ , " copyright = " <> (pack . show . copyright) pkgDesc , "" , " author :: IsString a => a"- , " author = \"" <> (pack . ft . author) pkgDesc <> "\""+ , " author = \"" <> (pack . fromShortText . author) pkgDesc <> "\"" , "" , " homepage :: IsString a => a"- , " homepage = \"" <> (pack . ft . homepage) pkgDesc <> "\""+ , " homepage = \"" <> (pack . fromShortText . homepage) pkgDesc <> "\"" , "" , " package :: IsString a => a" , " package = \"" <> (pack . display . package) pkgDesc <> "\""@@ -382,12 +363,7 @@ fileText file = doesFileExist file >>= \x -> if x then B.readFile file else return ""--#if MIN_VERSION_Cabal(3,6,0) fileTextStr = fileText . getSymbolicPath-#else- fileTextStr = fileText-#endif hgInfo :: IO (String, String, String)@@ -418,4 +394,4 @@ ++ (if cr /= "" then ", " ++ cr else "") ++ "]" where- cr = (unwords . words . ft . I.copyright) a+ cr = (unwords . words . fromShortText . I.copyright) a
configuration-tools.cabal view
@@ -1,25 +1,25 @@-cabal-version: 2.2+cabal-version: 3.0 name: configuration-tools-version: 0.6.1+version: 0.7.0 synopsis: Tools for specifying and parsing configurations description: Tools for specifying and parsing configurations- .+ This package provides a collection of utils on top of the packages <http://hackage.haskell.org/package/optparse-applicative optparse-applicative>, <http://hackage.haskell.org/package/aeson aeson>, and <http://hackage.haskell.org/package/yaml yaml> for configuring libraries and applications in a convenient and composable way.- .+ The main features are- .+ 1. configuration management through integration of command line option parsing and configuration files and- .+ 2. a @Setup.hs@ file that generates a @PkgInfo@ module for each component of a package that provides information about the package and the build.- .+ Documentation on how to use this package can be found in the <https://github.com/alephcloud/hs-configuration-tools/blob/master/README.md README> and in the API documentation of the modules "Configuration.Utils" and@@ -33,14 +33,16 @@ maintainer: Lars Kuhtz <lakuhtz@gmail.com> copyright: (c) 2019-2020 Colin Woodbury <colin@fosskers.ca>,- (c) 2015-2021 Lars Kuhtz <lakuhtz@gmail.com>,+ (c) 2015-2023 Lars Kuhtz <lakuhtz@gmail.com>, (c) 2014-2015 AlephCloud, Inc. category: Configuration, Console build-type: Custom tested-with:- GHC==9.0.1+ , GHC==9.6+ , GHC==9.4+ , GHC==9.2+ , GHC==9.0.1 , GHC==8.10.7- , GHC==8.8.4 extra-doc-files: README.md,@@ -48,8 +50,8 @@ custom-setup setup-depends:- Cabal >= 2.2,- base >= 4.11 && < 5.0,+ Cabal >= 3.6 && < 100,+ base >= 4.14 && < 5.0, bytestring >= 0.10.0.2, directory >= 1.2.1.0, filepath >= 1.3.0.1,@@ -95,11 +97,11 @@ Configuration.Utils.Internal.HttpsCertPolicy build-depends:- Cabal >= 2.2+ Cabal >= 3.6 , aeson >= 0.7.0.6- , ansi-wl-pprint >= 0.6+ , prettyprinter >= 1.7 , attoparsec >= 0.11.3.4- , base >= 4.11 && < 5+ , base >= 4.14 && < 5 , base-unicode-symbols >= 0.2.2.4 , bytestring >= 0.10.0.2 , case-insensitive >= 1.2@@ -109,7 +111,7 @@ , filepath >= 1.3.0.1 , mtl >= 2.2 , network-uri >= 2.6.0.1- , optparse-applicative >= 0.11.0.2+ , optparse-applicative >= 0.18 , process >= 1.2.0.0 , profunctors >= 4.0.4 , semigroups >= 0.18@@ -123,17 +125,17 @@ if flag(remote-configs) build-depends: base64-bytestring >= 1.0- , connection >= 0.2+ , crypton-connection >= 0.3+ , crypton-x509 >= 1.5+ , crypton-x509-system >= 1.5+ , crypton-x509-validation >= 1.5.1 , data-default >= 0.5 , enclosed-exceptions >= 1.0- , http-client >= 0.4.30- , http-client-tls >= 0.2+ , http-client >= 0.5+ , http-client-tls >= 0.3 , http-types >= 0.8 , monad-control >= 1.0 , tls >= 1.2- , x509 >= 1.5- , x509-system >= 1.5- , x509-validation >= 1.5.1 if flag(remote-configs) cpp-options: -DREMOTE_CONFIGS@@ -156,8 +158,8 @@ PkgInfo build-depends:- Cabal >= 2.2- , base >= 4.11 && < 5+ Cabal >= 3.6+ , base >= 4.14 && < 5 , base-unicode-symbols >= 0.2.2.4 , bytestring >= 0.10 , configuration-tools@@ -172,9 +174,9 @@ enclosed-exceptions >= 1.0 , http-types >= 0.8 , monad-control >= 1.0- , wai >= 3.0- , warp >= 3.0- , warp-tls >= 3.0+ , wai >= 3.2+ , warp >= 3.3+ , warp-tls >= 3.4 , network >= 2.8 cpp-options: -DREMOTE_CONFIGS@@ -193,9 +195,9 @@ PkgInfo build-depends:- base >= 4.11 && < 5+ base >= 4.14 && < 5 , base-unicode-symbols >= 0.2.2.4- , Cabal >= 2.2+ , Cabal >= 3.6 , configuration-tools executable example@@ -209,8 +211,8 @@ autogen-modules: PkgInfo build-depends:- base >= 4.11 && < 5+ base >= 4.14 && < 5 , base-unicode-symbols >= 0.2.2.4- , Cabal >= 2.2+ , Cabal >= 3.6 , configuration-tools , mtl >= 2.2
examples/Example.hs view
@@ -40,11 +40,7 @@ import Data.Monoid.Unicode -#if MIN_VERSION_base(4,13,0) import Prelude.Unicode hiding ((×))-#else-import Prelude.Unicode-#endif -- This assumes usage of cabal with custom Setup.hs --
src/Configuration/Utils.hs view
@@ -4,6 +4,7 @@ {-# LANGUAGE RankNTypes #-} {-# LANGUAGE RecordWildCards #-} {-# LANGUAGE ScopedTypeVariables #-}+{-# LANGUAGE TypeApplications #-} {-# LANGUAGE UnicodeSyntax #-} {-# OPTIONS_HADDOCK show-extensions #-}@@ -132,8 +133,10 @@ import Configuration.Utils.Operators import Configuration.Utils.Validation -import Control.Monad.Except hiding (mapM_)-import Control.Monad.Writer hiding (mapM_)+import Control.Monad (void, when)+import Control.Monad.Except (MonadError, throwError)+import Control.Monad.Writer (execWriterT, runWriterT)+import Control.Monad.IO.Class (MonadIO) import qualified Data.ByteString.Char8 as B8 import qualified Data.CaseInsensitive as CI@@ -150,15 +153,11 @@ import qualified Options.Applicative as O import Prelude hiding (any, concatMap, mapM_)-#if MIN_VERSION_base(4,13,0) import Prelude.Unicode hiding ((×))-#else-import Prelude.Unicode-#endif import System.IO -import qualified Text.PrettyPrint.ANSI.Leijen as P+import qualified Prettyprinter as P #ifdef REMOTE_CONFIGS import Control.Monad.Trans.Control@@ -589,7 +588,7 @@ $ O.progDesc _piDescription ⊕ O.fullDesc ⊕ maybe mempty O.header _piHelpHeader- ⊕ O.footerDoc (Just $ defaultFooter ⊕ maybe mempty P.text _piHelpFooter)+ ⊕ O.footerDoc (Just $ defaultFooter ⊕ maybe mempty P.pretty _piHelpFooter) where optionParser = -- these are identity parsers that are only applied for their side effects@@ -599,11 +598,7 @@ -- the 'O.helper' option from optparse-applicative is hidden by default -- which seems a bit weired. This option doesn't hide the access to help.-#if MIN_VERSION_optparse_applicative(0,16,0) nonHiddenHelper = abortOption (ShowHelpText Nothing)-#else- nonHiddenHelper = abortOption ShowHelpText-#endif % long "help" ⊕ short 'h' ⊕ short '?'@@ -626,25 +621,26 @@ , "" ] + a </> b = a <> P.softline <> b+ staticFiles | null _piConfigurationFiles = Nothing | otherwise = Just $ \n → P.hang 3 $ P.vsep- [ P.int n ⊕ "." P.</> par "Configuration files at the following locations:"+ [ P.pretty @Int n ⊕ "." </> par "Configuration files at the following locations:" , P.vsep $ map (\f → "* " ⊕ printConfigFile f) _piConfigurationFiles ] cmdFiles = Just $ \n → P.hang 3 $ P.fillSep- [ P.int n ⊕ "." P.</> par "Configuration files from locations provided through"+ [ P.pretty n ⊕ "." </> par "Configuration files from locations provided through" , par "--config-file options in the order as they appear." ] cmdOptions = Just $ \n → P.hang 3- $ P.int n ⊕ "." P.</> par "Command line options."+ $ P.pretty n ⊕ "." </> par "Command line options." - printConfigFile f = P.text (T.unpack $ getConfigFile f) P.<+> case f of- ConfigFileRequired _ → P.text "(required)"- ConfigFileOptional _ → P.text "(optional)"+ printConfigFile f = P.pretty (getConfigFile f) P.<+> case f of+ ConfigFileRequired _ → "(required)"+ ConfigFileOptional _ → "(optional)" - par ∷ String → P.Doc- par = P.fillSep ∘ map P.string ∘ words+ par = P.fillSep ∘ map P.pretty ∘ words -- | Internal main function --
src/Configuration/Utils/CommandLine.hs view
@@ -56,7 +56,6 @@ import Configuration.Utils.Operators import Control.Applicative-import Control.Monad.Writer hiding (mapM_) import Data.Aeson import qualified Data.ByteString.Lazy.Char8 as BL8@@ -76,11 +75,7 @@ import qualified Text.ParserCombinators.ReadP as P hiding (string) -#if MIN_VERSION_base(4,13,0) import Prelude.Unicode hiding ((×))-#else-import Prelude.Unicode-#endif -- -------------------------------------------------------------------------- --
src/Configuration/Utils/Http.hs view
@@ -55,11 +55,7 @@ import Data.Maybe (isJust) import Data.Monoid.Unicode -#if MIN_VERSION_base(4,13,0) import Prelude.Unicode hiding ((×))-#else-import Prelude.Unicode-#endif -- -------------------------------------------------------------------------- -- -- Http Service TLS Configuration
src/Configuration/Utils/Internal/HttpsCertPolicy.hs view
@@ -4,10 +4,6 @@ {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE UnicodeSyntax #-} -#ifndef MIN_VERSION_http_client-#define MIN_VERSION_http_client(x,y,z) 1-#endif- -- | -- Module: Configuration.Utils.Internal.HttpsCertPolicy -- Description: HTTPS certificate validation policy@@ -42,7 +38,6 @@ import Control.Exception (Exception, Handler(..), catches, throwIO) import Control.Monad.State-import Control.Monad.Writer import Data.Bifunctor import qualified Data.ByteString.Base64 as B64@@ -64,11 +59,7 @@ import qualified Options.Applicative as O import Prelude hiding (any, concatMap, mapM_)-#if MIN_VERSION_base(4,13,0) import Prelude.Unicode hiding ((×))-#else-import Prelude.Unicode-#endif import qualified Network.Connection as HTTP import qualified Network.HTTP.Client as HTTP@@ -163,15 +154,6 @@ [ Handler $ \(e ∷ TLS.TLSException) → do cert ← readIORef certVar handleTlsException request cert e-#if ! MIN_VERSION_http_client(0,5,0)- , Handler $ \httpEx → case httpEx of- HTTP.TlsException tlsEx → case fromException tlsEx of- Nothing → throwIO httpEx- Just e → do- cert ← readIORef certVar- handleTlsException request cert e- _ → throwIO httpEx-#endif ] -- -------------------------------------------------------------------------- --
src/Configuration/Utils/Monoid.hs view
@@ -32,8 +32,6 @@ import Configuration.Utils.CommandLine import Configuration.Utils.Internal -import Control.Monad.Writer hiding (mapM_, (<>))- import Data.Aeson import qualified Data.List.NonEmpty as NEL import Data.Semigroup
src/Configuration/Utils/Setup.hs view
@@ -111,15 +111,8 @@ import Distribution.Simple.PackageIndex import Distribution.Simple.Setup import Distribution.Text-import Distribution.Types.UnqualComponentName--#if MIN_VERSION_Cabal(3,6,0) import Distribution.Utils.Path-#endif--#if MIN_VERSION_Cabal(3,2,0) import Distribution.Utils.ShortText-#endif import System.Process @@ -169,13 +162,8 @@ prettyLicense :: I.InstalledPackageInfo -> String prettyLicense = either prettyShow prettyShow . I.license -#if MIN_VERSION_Cabal(3,2,0) ft :: ShortText -> String ft = fromShortText-#else-ft :: String -> String-ft = id-#endif -- -------------------------------------------------------------------------- -- -- Cabal 2.0@@ -238,11 +226,7 @@ trim = f . f where f = reverse . dropWhile isSpace -#if defined (MIN_VERSION_Cabal) && MIN_VERSION_Cabal(3,4,0) getVCS :: IO (Maybe KnownRepoType)-#else-getVCS :: IO (Maybe RepoType)-#endif getVCS = getCurrentDirectory >>= getVcsOfDir where getVcsOfDir d = do@@ -382,12 +366,7 @@ fileText file = doesFileExist file >>= \x -> if x then B.readFile file else return ""--#if MIN_VERSION_Cabal(3,6,0) fileTextStr = fileText . getSymbolicPath-#else- fileTextStr = fileText-#endif hgInfo :: IO (String, String, String)
test/TestExample.hs view
@@ -35,11 +35,7 @@ import Example hiding (main) -#if MIN_VERSION_base(4,13,0) import Prelude.Unicode hiding ((×))-#else-import Prelude.Unicode-#endif import PkgInfo
test/TestTools.hs view
@@ -61,11 +61,7 @@ import Distribution.Simple.Utils (withTempFile) -#if MIN_VERSION_base(4,13,0) import Prelude.Unicode hiding ((×))-#else-import Prelude.Unicode-#endif import System.Environment import System.IO
test/Tests/MonoidConfig.hs view
@@ -31,11 +31,7 @@ import Data.String import qualified Data.Text as T -#if MIN_VERSION_base(4,13,0) import Prelude.Unicode hiding ((×))-#else-import Prelude.Unicode-#endif -- -------------------------------------------------------------------------- -- -- Test cases