argparser-0.3.3: Command line parsing framework for console applications

Copyright(c) Simon Bergot
LicenseBSD3
Maintainersimon.bergot@gmail.com
Stabilityunstable
Portabilityportable
Safe HaskellSafe-Inferred
LanguageHaskell98

System.Console.ArgParser.Params

Contents

Description

Parameters are basic building blocks of a command line parser.

Synopsis

Standard constructors

Constructor

data StdArgParam a Source

Defines a parameter consuming arguments on the command line. The source defines whether the arguments are positional:

myprog posarg1 posarg2 ...

... or are taken from a flag:

myprog --myflag flagarg1 flagarg2 ...

short form:

myprog -m flagarg1 flagarg2 ...

One can provide two signatures of parsing function using the 'ArgParser type':

Misc types

data ArgSrc Source

Defines the source of a parameter: either positional or flag.

Constructors

Flag 
Pos 

data FlagFormat Source

Specify the format of a flag

Constructors

Short

Possible short format ie -f or --foo

Long

Only long format ie --foo

data ArgParser a Source

Defines the number of args consumed by a standard parameter

Constructors

SingleArgParser (Arg -> ParseResult a)

Uses exactly one arg

MulipleArgParser (Args -> ParseResult a)

Uses any number of args

data Optionality a Source

Defines whether a parameter is mandatory or optional. When a parameter is marked as Optional, a default value must be provided.

Constructors

Mandatory 
Optional a 

type Key = String Source

identifier used to specify the name of a flag or a positional argument.

Special constructors

data FlagParam a Source

A simple command line flag. The parsing function will be passed True if the flag is present, if the flag is provided to the command line, and False otherwise. For a key foo, the flag can either be --foo or -f

Constructors

FlagParam FlagFormat Key (Bool -> a) 

Instances

data Descr spec a infixl 2 Source

Allows the user to provide a description for a particular parameter. Can be used as an infix operator:

myparam `Descr` "this is my description"

Constructors

Descr infixl 2 

Fields

getdvalue :: spec a
 
getuserdescr :: String
 

Instances

ParamSpec spec => ParamSpec (Descr spec) 

data MetaVar spec a infixl 2 Source

Allows the user to provide a description for a particular parameter. Can be used as an infix operator:

myparam `Descr` "this is my description"

Constructors

MetaVar infixl 2 

Fields

getmvvalue :: spec a
 
getusermvar :: String
 

Instances

ParamSpec spec => ParamSpec (MetaVar spec)