Module OptParse

Summary of exported operations:

long :: String -> Mod  Deterministic 
Set the long name of an option.
short :: String -> Mod  Deterministic 
Set the short name of an option.
optional :: Mod  Deterministic 
Set the optional flag of an argument.
metavar :: String -> Mod  Deterministic 
Set the metavar of an argument.
help :: String -> Mod  Deterministic 
Set the help text of an argument.
(<>) :: Mod -> Mod -> Mod  Deterministic 
Combine two modifiers.
option :: (String -> a) -> Mod -> [Parser a]  Deterministic 
Create an option.
arg :: (String -> a) -> Mod -> [Parser a]  Deterministic 
Create a positional argument.
rest :: (String -> a) -> Mod -> [Parser a]  Deterministic 
Create an argument that consumes the rest of the command line.
flag :: a -> Mod -> [Parser a]  Deterministic 
Create a flag.
(<.>) :: [a] -> [a] -> [a]  Deterministic 
Combine two arguments.
(<|>) :: [a] -> [a] -> [a]  Deterministic 
Combine command sub parsers.
command :: String -> Mod -> a -> [Parser a] -> [(String,ArgProps,a,ParseSpec a)]  Deterministic 
Create a sub-parser for a command.
optParser :: [Parser a] -> ParseSpec a  Deterministic 
Create a parse spec from a list of parsers.
commands :: Mod -> [(String,ArgProps,a,ParseSpec a)] -> [Parser a]  Deterministic 
Create a command parser.
printUsage :: String -> Int -> ParseSpec a -> IO ()  Deterministic 
Print usage information for a command line parser specification.
renderUsage :: String -> Int -> ParseSpec a -> String  Deterministic 
Render usage information to a string.
parse :: String -> ParseSpec a -> String -> Either String [a]  Deterministic 
Parses a command line via a parser spec.

Exported datatypes:


Arg

A command line argument. Used to represent a parsed command line.

Constructors:


Parser

A partial command line parser.

Constructors:


ParseSpec

A parser specification. A collection of parsers.

Constructors:


ArgProps

Properties that for all parser types.

Constructors:


OptProps

Properties for option/flag parsers.

Constructors:


Mod

Modifiers for argument and option properties.

Constructors:


Exported operations:

long :: String -> Mod  Deterministic 

Set the long name of an option.

Further infos:
  • solution complete, i.e., able to compute all solutions

short :: String -> Mod  Deterministic 

Set the short name of an option.

Further infos:
  • solution complete, i.e., able to compute all solutions

optional :: Mod  Deterministic 

Set the optional flag of an argument.

Further infos:
  • solution complete, i.e., able to compute all solutions

metavar :: String -> Mod  Deterministic 

Set the metavar of an argument. The metavar is used to print usage information.

Further infos:
  • solution complete, i.e., able to compute all solutions

help :: String -> Mod  Deterministic 

Set the help text of an argument. Used to print usage information.

Further infos:
  • solution complete, i.e., able to compute all solutions

(<>) :: Mod -> Mod -> Mod  Deterministic 

Combine two modifiers.

option :: (String -> a) -> Mod -> [Parser a]  Deterministic 

Create an option.

Example call:
(option f m)
Parameters:
  • f : function that converts the parsed value into a parse result
  • m : modifiers for this argument

arg :: (String -> a) -> Mod -> [Parser a]  Deterministic 

Create a positional argument.

Example call:
(arg f m)
Parameters:
  • f : function that converts the parsed value into a parse result
  • m : modifiers for this argument

rest :: (String -> a) -> Mod -> [Parser a]  Deterministic 

Create an argument that consumes the rest of the command line.

Example call:
(rest f m)
Parameters:
  • f : function that converts the parsed value into a parse result
  • m : modifiers for this argument

flag :: a -> Mod -> [Parser a]  Deterministic 

Create a flag.

Example call:
(flag a m)
Parameters:
  • a : result of the parser
  • m : modifiers for this argument

(<.>) :: [a] -> [a] -> [a]  Deterministic 

Combine two arguments.

Further infos:
  • defined as left-associative infix operator with precedence 4
  • solution complete, i.e., able to compute all solutions

(<|>) :: [a] -> [a] -> [a]  Deterministic 

Combine command sub parsers.

Further infos:
  • defined as left-associative infix operator with precedence 5
  • solution complete, i.e., able to compute all solutions

command :: String -> Mod -> a -> [Parser a] -> [(String,ArgProps,a,ParseSpec a)]  Deterministic 

Create a sub-parser for a command. Must be used with commands.

Example call:
(command n m a ps)
Parameters:
  • n : the name of the command
  • m : modifiers for this command
  • a : the result of this parse
  • ps : parsers for the rest of the command line for this command

optParser :: [Parser a] -> ParseSpec a  Deterministic 

Create a parse spec from a list of parsers.

Further infos:
  • solution complete, i.e., able to compute all solutions

commands :: Mod -> [(String,ArgProps,a,ParseSpec a)] -> [Parser a]  Deterministic 

Create a command parser.

Example call:
(commands m cs)
Parameters:
  • m : modifiers for this command
  • cs : command sub-parsers, created by command

printUsage :: String -> Int -> ParseSpec a -> IO ()  Deterministic 

Print usage information for a command line parser specification.

Example call:
(printUsage p c p)
Parameters:
  • p : the name of the current program
  • c : the maximum number of columns to use
  • p : the parser specification

renderUsage :: String -> Int -> ParseSpec a -> String  Deterministic 

Render usage information to a string.

Example call:
(renderUsage p c p)
Parameters:
  • p : the name of the current program
  • c : the maximum number of columns to use
  • p : the parser specification

parse :: String -> ParseSpec a -> String -> Either String [a]  Deterministic 

Parses a command line via a parser spec.

Example call:
(parse l s p)
Parameters:
  • l : the command line
  • s : the parser spec
  • p : the name of the current program