-
Notifications
You must be signed in to change notification settings - Fork 7
/
envparse.cabal
117 lines (113 loc) · 2.78 KB
/
envparse.cabal
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
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: [email protected]
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