envparse-0.6.0: envparse.cabal
name: envparse
version: 0.6.0
synopsis: Parse environment variables
description:
Here's a simple example of a program that uses @envparse@'s parser:
.
@
module Main (main) where
.
import Control.Monad (unless)
import Env
.
data Hello = Hello { name :: String, quiet :: Bool }
.
hello :: IO Hello
hello = Env.parse (header \"envparse example\") $
  Hello \<$\> var (str <=< nonempty) \"NAME\" (help \"Target for the greeting\")
  \<*\> switch \"QUIET\" (help \"Whether to actually print the greeting\")
 
main :: IO ()
main = do
  Hello {name, quiet} <- hello
  unless quiet $
  putStrLn (\"Hello, \" ++ name ++ \"!\")
@
.
The @NAME@ environment variable is mandatory and contains the name of the person to
greet. @QUIET@, on the other hand, is an optional boolean flag, false by default, that
decides whether the greeting should be silent.
.
If the @NAME@ variable is undefined in the environment then running the program will
result in the following help text:
.
@
envparse example
 
Available environment variables:
 
  NAME Target for the greeting
  QUIET Whether to actually print the
  greeting
 
Parsing errors:
 
  NAME is unset
@
homepage: https://supki.github.io/envparse
license: BSD3
license-file: LICENSE
author: Matvey Aksenov
maintainer: matvey.aksenov@gmail.com
copyright: 2015 Matvey Aksenov
category: System
build-type: Simple
cabal-version: >= 1.10
tested-with: GHC == 8.0.2, GHC == 8.2.2, GHC == 8.4.3
extra-source-files:
README.markdown
CHANGELOG.markdown
example/Main.hs
example/CustomError.hs
example/Generic0.hs
example/Generic1.hs
source-repository head
type: git
location: https://github.com/supki/envparse
source-repository this
type: git
location: https://github.com/supki/envparse
tag: 0.6.0
library
default-language:
Haskell2010
build-depends:
base
>= 4.6 && < 5
, containers
hs-source-dirs:
src
exposed-modules:
Env
Env.Internal.Error
Env.Internal.Free
Env.Internal.Help
Env.Internal.Val
Env.Internal.Parser
if impl(ghc >= 7.10)
exposed-modules:
Env.Generic
ghc-options:
-Wall
test-suite spec
default-language:
Haskell2010
type:
exitcode-stdio-1.0
build-depends:
base
>= 4.6 && < 5
, containers
, envparse
, hspec
, text
hs-source-dirs:
test
main-is:
Spec.hs
other-modules:
EnvSpec
Env.GenericSpec
Env.Internal.ParserSpec
ghc-options:
-Wall