opt-env-conf-0.2.0.0: Settings parsing for Haskell: command-line arguments, environment variables, and configuration values.
Safe HaskellSafe-Inferred
LanguageHaskell2010

OptEnvConf.Setting

Synopsis

Documentation

data Setting a Source #

A setting for parsing and documenting a single value.

Constructors

Setting 

Fields

Builders

help :: String -> Builder a Source #

Document a setting

Multiple helps concatenate help on new lines.

metavar :: String -> Builder a Source #

Document an option or env var.

Multiple metavars override eachother.

argument :: Builder a Source #

Try to parse an argument.

You'll also need to add a reader.

Multiple arguments are redundant.

option :: Builder a Source #

Try to parse an argument.

You'll also need to add a reader, at least one long or short, and a metavar.

Multiple options are redundant.

switch :: a -> Builder a Source #

Try to parse a switch, activate the given value when succesful

You'll also need to add at least one long or short.

Multiple switchs override eachother.

reader :: Reader a -> Builder a Source #

Declare how to parse an argument, option, or environment variable.

str :: IsString s => Reader s Source #

Read a string as-is.

This is the reader you will want to use for reading a String.

This is different from auto for strings because Read wants to parse quotes when parsing Strings.

auto :: Read a => Reader a Source #

Read via the Read instance

You cannot use this for bare strings, because Read for strings parses quotes.

long :: String -> Builder a Source #

Try to parse this long option or switch.

long "foo" corresponds to --foo

Notes: * Parsing options with an empty name in the long is not supported. * Parsing options with an '=' sign in the long is not supported.

Multiple longs will be tried in order. Empty longs will be ignored.

short :: Char -> Builder a Source #

Try to parse this short option or switch.

short f corresponds to -f

Notes: * Parsing options with short - is not supported.

Multiple shorts will be tried in order.

env :: String -> Builder a Source #

Try to parse an environment variable.

You'll also need to add a reader and a metavar.

Multiple envs will be tried in order.

conf :: HasCodec a => String -> Builder a Source #

Try to parse a configuration value at the given key.

Multiple confs will be tried in order.

confWith :: String -> ValueCodec void a -> Builder a Source #

Like conf but with a custom Codec for parsing the value.

confWith' :: String -> ValueCodec void (Maybe a) -> Builder a Source #

Like confWith but allows interpreting Null as a value other than "Not found".

name :: HasCodec a => String -> Builder a Source #

Short-hand function for option, long, env, and conf at the same time.

Multiple names will be tried in order.

value :: Show a => a -> Builder a Source #

Set the default value

Multiple values override eachother.

API Note: default is not a valid identifier in Haskell. I'd also have preferred default instead.

valueWithShown :: a -> String -> Builder a Source #

Set the default value, along with a shown version of it.

example :: String -> Builder a Source #

Provide an example value for documentation.

The example is provided as a literal string.

If you use reader auto, you'll want to use shownExample instead.

shownExample :: Show a => a -> Builder a Source #

Use Show to show an example.

This only makes sense if you use reader auto.

hidden :: Builder a Source #

Don't show this setting in documentation

Multiple hiddens are redundant.

newtype Builder a Source #

Builder for a Setting

Constructors

Builder 

Fields

Instances

Instances details
Monoid (Builder f) Source # 
Instance details

Defined in OptEnvConf.Setting

Methods

mempty :: Builder f #

mappend :: Builder f -> Builder f -> Builder f #

mconcat :: [Builder f] -> Builder f #

Semigroup (Builder f) Source # 
Instance details

Defined in OptEnvConf.Setting

Methods

(<>) :: Builder f -> Builder f -> Builder f #

sconcat :: NonEmpty (Builder f) -> Builder f #

stimes :: Integral b => b -> Builder f -> Builder f #

Internal

showSettingABit :: Setting a -> ShowS Source #

Show a Setting as much as possible, for debugging

emptySetting :: Setting a Source #

A mempty Setting to build up a setting from.

data DecodingCodec a Source #

Constructors

forall void. DecodingCodec (ValueCodec void (Maybe a))