console-program- Interpret the command line and contents of a config file as commands and options

Safe HaskellSafe-Inferred




This module contains functions to create option descriptions, together with their argument types.


Option descriptions

data Option a Source

A value of type Option a describes an option, that delivers a value to the program of type a.



:: [Char]

List of short option characters.

-> [String]

List of long option strings.

-> Type a

Type of option argument.

-> a

Default value.

-> String


-> Option a

The resulting option description.

Create an option description.

Options can have arguments, as in myprogram --foo=bar, where bar is the argument to foo. These arguments have types, dictated by the particular option; this type is the third parameter to option.

data Type a Source

A Type a represents the type of an option or argument.

Further below you can find some common types of option arguments.




parser :: String -> Either String a

Parse the option argument into a value (Right) or signal a parsing error (Left).

name :: String

A name for this type of option argument (for usage info).

defaultValue :: Maybe a

The default value, when the option occurs without option argument. Nothing means that an argument is required for this type of option.


Argument types



:: a

Default value.

-> Type a 
-> Type a 

string :: Type StringSource

A plain string.

boolean :: Type BoolSource

A boolean. Argument can be "1","0","true","false","on","off","yes","no".

directory :: Type FilePathSource

A directory path. A trailing slash is stripped, if present.

file :: Type FilePathSource

A file path.

device :: Type FilePathSource

A device path.

natural :: Type IntegerSource

A natural number (in decimal).

integer :: Type IntegerSource

An integer number (in decimal).