Copyright | (c) Simon Bergot |
---|---|
License | BSD3 |
Maintainer | simon.bergot@gmail.com |
Stability | unstable |
Portability | portable |
Safe Haskell | Safe-Inferred |
Language | Haskell98 |
Parameters are basic building blocks of a command line parser.
- data StdArgParam a = StdArgParam (Optionality a) ArgSrc Key (ArgParser a)
- data ArgSrc
- data FlagFormat
- data ArgParser a
- = SingleArgParser (Arg -> ParseResult a)
- | MulipleArgParser (Args -> ParseResult a)
- data Optionality a
- type Key = String
- data FlagParam a = FlagParam FlagFormat Key (Bool -> a)
- data Descr spec a = Descr {
- getdvalue :: spec a
- getuserdescr :: String
- data MetaVar spec a = MetaVar {
- getmvvalue :: spec a
- getusermvar :: String
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':
SingleArgParser
means that the parameter expect exactly one argMulipleArgParser
means that the parameter expect any number of args
StdArgParam (Optionality a) ArgSrc Key (ArgParser a) |
Misc types
data FlagFormat Source
Specify the format of a flag
Defines the number of args consumed by a standard parameter
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.
Special constructors
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
FlagParam FlagFormat Key (Bool -> a) |
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"
Descr infixl 2 | |
|
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"
MetaVar infixl 2 | |
|