optparse-applicative-0.9.1.1: Utilities and combinators for parsing command line options

Safe HaskellSafe-Inferred
LanguageHaskell98

Options.Applicative.Extra

Contents

Synopsis

Extra parser utilities

This module contains high-level functions to run parsers.

helper :: Parser (a -> a)

A hidden "helper" option which always fails.

execParser :: ParserInfo a -> IO a

Run a program description.

Parse command line arguments. Display help text and exit if any parse error occurs.

execParserMaybe :: ParserInfo a -> [String] -> Maybe a

Run a program description in pure code.

This function behaves like execParser, but can be called from pure code. Note that, in case of errors, no message is displayed, and this function simply returns Nothing.

If you need to keep track of error messages, use execParserPure instead.

customExecParser :: ParserPrefs -> ParserInfo a -> IO a

Run a program description with custom preferences.

customExecParserMaybe :: ParserPrefs -> ParserInfo a -> [String] -> Maybe a

Run a program description with custom preferences in pure code.

See execParserMaybe for details.

execParserPure

Arguments

:: ParserPrefs

Global preferences for this parser

-> ParserInfo a

Description of the program to run

-> [String]

Program arguments

-> ParserResult a 

The most general way to run a program description in pure code.

newtype ParserFailure

Constructors

ParserFailure 

Instances

data ParserResult a

Result of execParserPure.

Instances

data ParserPrefs

Global preferences for a top-level Parser.

Constructors

ParserPrefs 

Fields

prefMultiSuffix :: String

metavar suffix for multiple options

prefDisambiguate :: Bool

automatically disambiguate abbreviations (default: False)

prefShowHelpOnError :: Bool

always show help text on parse errors (default: False)

prefBacktrack :: Bool

backtrack to parent parser when a subcommand fails (default: True)

prefColumns :: Int

number of columns in the terminal, used to format the help page (default: 80)