hasql-optparse-applicative 0.2.4 → 0.3
raw patch · 3 files changed
+66/−68 lines, 3 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
- Hasql.Options.Applicative: connectionSettings :: Maybe String -> Parser Settings
- Hasql.Options.Applicative: poolSettings :: Maybe String -> Parser Settings
+ Hasql.OptparseApplicative: connectionSettings :: (String -> String) -> Parser Settings
+ Hasql.OptparseApplicative: poolSettings :: (String -> String) -> Parser Settings
Files
- hasql-optparse-applicative.cabal +2/−2
- library/Hasql/Options/Applicative.hs +0/−66
- library/Hasql/OptparseApplicative.hs +64/−0
hasql-optparse-applicative.cabal view
@@ -1,7 +1,7 @@ name: hasql-optparse-applicative version:- 0.2.4+ 0.3 synopsis: "optparse-applicative" parsers for "hasql" category:@@ -42,7 +42,7 @@ Haskell2010 other-modules: exposed-modules:- Hasql.Options.Applicative+ Hasql.OptparseApplicative build-depends: hasql >= 0.19 && < 0.20 || >= 1 && < 2, hasql-pool >= 0.4 && < 0.5,
− library/Hasql/Options/Applicative.hs
@@ -1,66 +0,0 @@-module Hasql.Options.Applicative where--import BasePrelude-import Options.Applicative-import qualified Hasql.Connection-import qualified Hasql.Pool----- |--- Given a prefix for long names produces a parser of @Hasql.Pool.'Hasql.Pool.Settings'@.-poolSettings :: Maybe String -> Parser Hasql.Pool.Settings-poolSettings prefix =- (,,) <$> size <*> timeout <*> connectionSettings prefix- where- size =- option auto $- long (prefixed "pool-size") <>- value 1 <>- showDefault <>- help "Amount of connections in the pool"- timeout =- fmap fromIntegral $- option auto $- long (prefixed "pool-timeout") <>- value 10 <>- showDefault <>- help "Amount of seconds for which the unused connections are kept open"- prefixed =- maybe id (\prefix string -> prefix <> "-" <> string) prefix---- |--- Given a prefix for long names produces a parser of @Hasql.Connection.'Hasql.Connection.Settings'@.-connectionSettings :: Maybe String -> Parser Hasql.Connection.Settings-connectionSettings prefix =- Hasql.Connection.settings <$> host <*> port <*> user <*> password <*> database- where- host =- fmap fromString $ strOption $- long (prefixed "host") <> - value "127.0.0.1" <>- showDefault <>- help "Server host"- port =- option auto $- long (prefixed "port") <>- value 5432 <>- showDefault <>- help "Server port"- user =- fmap fromString $ strOption $- long (prefixed "user") <>- value "postgres" <>- showDefault <>- help "Username"- password =- fmap fromString $ strOption $- long (prefixed "password") <>- value "" <>- showDefault <>- help "Password"- database =- fmap fromString $ strOption $- long (prefixed "database") <>- help "Database name"- prefixed s = - maybe s (<> ("-" <> s)) prefix
+ library/Hasql/OptparseApplicative.hs view
@@ -0,0 +1,64 @@+module Hasql.OptparseApplicative where++import BasePrelude+import Options.Applicative+import qualified Hasql.Connection as A+import qualified Hasql.Pool as B+++-- |+-- Given a function, which updates the long names produces a parser of @B.'B.Settings'@.+-- You can use this function to prefix the name or you can just specify 'id', if you don't want it changed.+poolSettings :: (String -> String) -> Parser B.Settings+poolSettings updatedName =+ (,,) <$> size <*> timeout <*> connectionSettings updatedName+ where+ size =+ option auto $+ long (updatedName "pool-size") <>+ value 1 <>+ showDefault <>+ help "Amount of connections in the pool"+ timeout =+ fmap fromIntegral $+ option auto $+ long (updatedName "pool-timeout") <>+ value 10 <>+ showDefault <>+ help "Amount of seconds for which the unused connections are kept open"++-- |+-- Given a function, which updates the long names produces a parser of @A.'A.Settings'@.+-- You can use this function to prefix the name or you can just specify 'id', if you don't want it changed.+connectionSettings :: (String -> String) -> Parser A.Settings+connectionSettings updatedName =+ A.settings <$> host <*> port <*> user <*> password <*> database+ where+ host =+ fmap fromString $ strOption $+ long (updatedName "host") <> + value "127.0.0.1" <>+ showDefault <>+ help "Server host"+ port =+ option auto $+ long (updatedName "port") <>+ value 5432 <>+ showDefault <>+ help "Server port"+ user =+ fmap fromString $ strOption $+ long (updatedName "user") <>+ value "postgres" <>+ showDefault <>+ help "Username"+ password =+ fmap fromString $ strOption $+ long (updatedName "password") <>+ value "" <>+ showDefault <>+ help "Password"+ database =+ fmap fromString $ strOption $+ long (updatedName "database") <>+ help "Database name"