envparse: Parse environment variables
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
[Skip to Readme]
Downloads
- envparse-0.3.0.tar.gz [browse] (Cabal source package)
- Package description (revised from the package)
Note: This package has metadata revisions in the cabal description newer than included in the tarball. To unpack the package including the revisions, use 'cabal get'.
Maintainer's Corner
For package maintainers and hackage trustees
Candidates
- No Candidates
Versions [RSS] | 0.1.0, 0.2.0, 0.2.1, 0.2.2, 0.3.0, 0.3.1, 0.3.2, 0.3.3, 0.4, 0.4.1, 0.5.0, 0.5.2, 0.6.0 (info) |
---|---|
Change log | CHANGELOG.markdown |
Dependencies | base (>=4.6 && <4.11), containers [details] |
Tested with | ghc ==7.6.3, ghc ==7.8.4, ghc ==7.10.3 |
License | BSD-3-Clause |
Copyright | 2015 Matvey Aksenov |
Author | Matvey Aksenov |
Maintainer | matvey.aksenov@gmail.com |
Revised | Revision 1 made by Bodigrim at 2022-06-18T17:22:03Z |
Category | System |
Home page | https://supki.github.io/envparse |
Source repo | head: git clone https://github.com/supki/envparse this: git clone https://github.com/supki/envparse(tag 0.3.0) |
Uploaded | by MatveyAksenov at 2016-03-12T11:54:36Z |
Distributions | LTSHaskell:0.6.0, NixOS:0.5.0, Stackage:0.6.0 |
Reverse Dependencies | 16 direct, 35 indirect [details] |
Downloads | 9641 total (18 in the last 30 days) |
Rating | (no votes yet) [estimated by Bayesian average] |
Your Rating | |
Status | Docs available [build log] Last success reported on 2016-11-27 [all 1 reports] |