packages feed

hasql-postgres-options (empty) → 0.1.0

raw patch · 4 files changed

+130/−0 lines, 4 filesdep +basedep +base-preludedep +bytestringsetup-changed

Dependencies added: base, base-prelude, bytestring, hasql-postgres, optparse-applicative

Files

+ LICENSE view
@@ -0,0 +1,22 @@+Copyright (c) 2014, Nikita Volkov++Permission is hereby granted, free of charge, to any person+obtaining a copy of this software and associated documentation+files (the "Software"), to deal in the Software without+restriction, including without limitation the rights to use,+copy, modify, merge, publish, distribute, sublicense, and/or sell+copies of the Software, and to permit persons to whom the+Software is furnished to do so, subject to the following+conditions:++The above copyright notice and this permission notice shall be+included in all copies or substantial portions of the Software.++THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES+OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT+HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,+WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING+FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR+OTHER DEALINGS IN THE SOFTWARE.
+ Setup.hs view
@@ -0,0 +1,2 @@+import Distribution.Simple+main = defaultMain
+ hasql-postgres-options.cabal view
@@ -0,0 +1,56 @@+name:+  hasql-postgres-options+version:+  0.1.0+synopsis:+  An "optparse-applicative" parser for "hasql-postgres"+category:+  Database, Options+homepage:+  https://github.com/nikita-volkov/hasql-postgres-options +bug-reports:+  https://github.com/nikita-volkov/hasql-postgres-options/issues +author:+  Nikita Volkov <nikita.y.volkov@mail.ru>+maintainer:+  Nikita Volkov <nikita.y.volkov@mail.ru>+copyright:+  (c) 2014, Nikita Volkov+license:+  MIT+license-file:+  LICENSE+build-type:+  Simple+cabal-version:+  >=1.10+++source-repository head+  type:+    git+  location:+    git://github.com/nikita-volkov/hasql-postgres-options.git+++library+  hs-source-dirs:+    library+  ghc-options:+    -funbox-strict-fields+  default-extensions:+    Arrows, BangPatterns, ConstraintKinds, DataKinds, DefaultSignatures, DeriveDataTypeable, DeriveFunctor, DeriveGeneric, EmptyDataDecls, FlexibleContexts, FlexibleInstances, FunctionalDependencies, GADTs, GeneralizedNewtypeDeriving, ImpredicativeTypes, LambdaCase, LiberalTypeSynonyms, MagicHash, MultiParamTypeClasses, MultiWayIf, NoImplicitPrelude, NoMonomorphismRestriction, OverloadedStrings, PatternGuards, ParallelListComp, QuasiQuotes, RankNTypes, RecordWildCards, ScopedTypeVariables, StandaloneDeriving, TemplateHaskell, TupleSections, TypeFamilies, TypeOperators, UnboxedTuples+  default-language:+    Haskell2010+  other-modules:+  exposed-modules:+    Hasql.Postgres.Options+  build-depends:+    hasql-postgres == 0.8.*,+    -- +    optparse-applicative == 0.11.*,+    -- +    bytestring == 0.10.*,+    --+    base-prelude >= 0.1.8 && < 0.2,+    base >= 4.5 && < 4.8
+ library/Hasql/Postgres/Options.hs view
@@ -0,0 +1,50 @@+module Hasql.Postgres.Options where++import BasePrelude+import Data.ByteString (ByteString)+import Options.Applicative+import qualified Hasql.Postgres as HP+++-- |+-- Given a prefix for long names produce a parser of 'HP.Settings'.+settings :: Maybe String -> Parser HP.Settings+settings prefix =+  HP.ParamSettings <$> host <*> port <*> user <*> password <*> database+  where+    host =+      option auto $+        long (applyPrefix "host") <> +        value "127.0.0.1" <>+        showDefault <>+        help "Server host"+    port =+      option auto $+        long (applyPrefix "port") <>+        value 5432 <>+        showDefault <>+        help "Server port"+    user =+      option auto $+        long (applyPrefix "user") <>+        value "postgres" <>+        showDefault <>+        help "Username"+    password =+      option auto $+        long (applyPrefix "password") <>+        value "" <>+        showDefault <>+        help "Password"+    database =+      option auto $+        long (applyPrefix "database") <>+        value "" <>+        showDefault <>+        help "Default database name"+    applyPrefix s = +      maybe s (<> ("-" <> s)) prefix++++