console-program-0.4.2.3: Interpret the command line and a config file as commands and options

System.Console.Argument

Description

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

Synopsis

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

Arguments

 :: [Char] List of short option characters. -> [String] List of long option strings. -> Type a Type of option argument. -> a Default value when the option is not specified by the user. -> String Description. -> 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.

Constructors

 Type Fieldsparser :: String -> Either String aParse the option argument into a value (Right) or signal a parsing error (Left).name :: StringA name for this type of option argument (for usage info).defaultValue :: Maybe aThe default value when the option occurs without option argument. Nothing means that an argument is required for this type of option.
Instances
 Source # Instance detailsDefined in System.Console.Argument Methodsfmap :: (a -> b) -> Type a -> Type b #(<\$) :: a -> Type b -> Type a #

# Argument types

Arguments

 :: a Default value. -> Type a -> Type a

A plain string.

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

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

A file path.

A device path.

A natural number (in decimal).

An integer number (in decimal).