Module

Options.Applicative.Extra

This module contains high-level functions to run parsers.

#helper

helper :: forall a. Parser (a -> a)

A hidden "helper" option which always fails. Use this to add the --help flag to your CLI parser

A common usage pattern is to apply this applicatively when creating a 'ParserInfo'

opts :: ParserInfo Sample opts = info (sample <**> helper) mempty

#hsubparser

hsubparser :: forall a. Mod CommandFields a -> Parser a

Builder for a command parser with a "helper" option attached. Used in the same way as subparser, but includes a --help|-h inside the subcommand.

#execParser

execParser :: forall a. ParserInfo a -> Effect a

Run a program description.

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

#customExecParser

customExecParser :: forall a. ParserPrefs -> ParserInfo a -> Effect a

Run a program description with custom preferences.

#execParserPure

execParserPure :: forall a. ParserPrefs -> ParserInfo a -> Array String -> ParserResult a

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

#getParseResult

getParseResult :: forall a. ParserResult a -> Maybe a

Extract the actual result from a ParserResult value.

This function returns 'Nothing' in case of errors. Possible error messages or completion actions are simply discarded.

If you want to display error messages and invoke completion actions appropriately, use 'handleParseResult' instead.

#handleParseResult

handleParseResult :: forall a. ParserResult a -> Effect a

Handle ParserResult.

#parserFailure

parserFailure :: forall a. ParserPrefs -> ParserInfo a -> ParseError -> Array Context -> ParserFailure ParserHelp

Generate a ParserFailure from a ParseError in a given Context.

This function can be used, for example, to show the help text for a parser:

handleParseResult <<< Failure $ parserFailure pprefs pinfo ShowHelpText mempty

Modules