ParserInfo packages a Parser with metadata used to execute command-line parsing and generate help text. Build one with info, combining the argument parser with helper and version parsers, then supply descriptions such as progDesc, header, and footer. section 15.3.1
Listing 15.14 An example ParserInfo
argumentParser :: ParserInfo Args
argumentParser =
info #1
( argsParser
<**> helper #2
<**> simpleVersioner "v1.0" #3
)
( fullDesc #4
<> progDesc "This is an example"
<> header "OPTPARSE APPLICATIVE EXAMPLE"
<> footer "Thanks for checking this example out!"
)
This complete definition combines an argument parser with --help and --version support, then adds program descriptions and surrounding help text. section 15.3.1
Execute a ParserInfo
After defining argumentParser :: ParserInfo Args, run it in IO with args <- execParser argumentParser. Missing required options produce usage guidance; supplying -s "Foo" -i 10 yields Args {arg1 = "Foo", arg2 = 10, arg3 = False, arg4 = Nothing}. Optional switches and arguments can then be added without changing their order. section 15.3.1
ParserInfo also supplies the boundary for nested command-line interfaces. A subparser associates command names such as list, add, and toggle with separate ParserInfo values, each carrying its own arguments and help description. section 17.3.2
