console-program-0.2.0.1: Interprets the command line and a config file as commands and options

System.Console.Argument

Contents

Synopsis

Documentation

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.

Constructors

Type 

Fields

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.

Note that this may be different from the corresponding value in the default configuration (the first argument of System.Console.Command.execute); the latter is what you get when this option does not occur at all in the configuration file or command line.

Instances

Argument types

optionalSource

Arguments

:: 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".

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).

Option descriptions

optionSource

Arguments

:: (a -> s)

Function that creates a setting (of type s) from the option argument.

-> [Char]

List of short option characters.

-> [String]

List of long option strings.

-> Type a

Type of option argument.

-> String

Description.

-> OptDescr (Either String s)

The resulting option description.

Create an option description. You need this to describe the options your command uses; see System.Console.Command.Command.