Module

Options.Applicative.Common

#liftOpt

liftOpt :: forall a. Option a -> Parser a

Create a parser composed of a single option.

#showOption

#runParserInfo

runParserInfo :: forall m a. MonadP m => ParserInfo a -> Args -> m a

#runParserFully

runParserFully :: forall m a. MonadP m => ArgPolicy -> Parser a -> Args -> m a

#runParser

runParser :: forall m a. MonadP m => ArgPolicy -> IsCmdStart -> Parser a -> Args -> m (Tuple a Args)

Apply a 'Parser' to a command line, and return a result and leftover arguments. This function returns an error if any parsing error occurs, or if any options are missing and don't have a default value.

#evalParser

evalParser :: forall a. Parser a -> Maybe a

The default value of a 'Parser'. This function returns an error if any of the options don't have a default value.

#mapParser

mapParser :: forall a b. (forall x. OptHelpInfo -> Option x -> b) -> Parser a -> Array b

Map a polymorphic function over all the options of a parser, and collect the results in a list.

#treeMapParser

treeMapParser :: forall a b. (forall x. OptHelpInfo -> Option x -> b) -> Parser a -> OptTree b

Like 'mapParser', but collect the results in a tree structure.

#optionNames

Re-exports from Options.Applicative.Types

#ParserPrefs

newtype ParserPrefs

Global preferences for a top-level 'Parser'. A 'ParserPrefs' contains general preferences for all command-line options, and can be built with the 'prefs' function.

Constructors

Instances

#ParserInfo

newtype ParserInfo a

A 'ParserInfo' describes a command line program, used to generate a help screen. Two help modes are supported: brief and full. In brief mode, only an option and argument summary is displayed, while in full mode each available option and command, including hidden ones, is described.

A basic 'ParserInfo' with default values for fields can be created using the 'info' function.

Constructors

Instances

#Parser

data Parser a

A 'Parser' is the core type in optparse-applicative. A value of type Parser a@ represents a specification for a set of options, which will yield a value of type a when the command line arguments are successfully parsed.

There are several types of primitive 'Parser'.

  • Flags: simple no-argument options. When a flag is encountered on the command line, its value is returned.

  • Options: options with an argument. An option can define a /reader/, which converts its argument from String to the desired value, or throws a parse error if the argument does not validate correctly.

  • Arguments: positional arguments, validated in the same way as option arguments.

  • Commands. A command defines a completely independent sub-parser. When a command is encountered, the whole command line is passed to the corresponding parser.

** Parser builders

Each parser builder takes an option modifier. A modifier can be created by composing the basic modifiers provided by here using the 'Monoid' operations mempty' and 'append', or their aliases 'idm' and '<>'.

For example:

out = strOption ( long "output" <> short 'o' <> metavar "FILENAME" )

creates a parser for an option called "output".

Instances

Modules