The latest version of envparse is 0.6.0-0.
envparse
Version 0.3.1 revision 1 uploaded by Bodigrim.
Package meta
- 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
- Author
- Matvey Aksenov
- Bug reports
- n/a
- Category
- System
- Copyright
- 2015 Matvey Aksenov
- Homepage
- https://supki.github.io/envparse
- Maintainer
- matvey.aksenov@gmail.com
- Package URL
- n/a
- Stability
- n/a