stack-1.4.0: The Haskell Tool Stack

Safe Haskell | Safe
Language | Haskell2010

Options.Applicative.Complicated

Description

Simple interface to complicated program arguments.

This is a "fork" of the `optparse-simple` package that has some workarounds for optparse-applicative issues that become problematic with programs that have many options and subcommands. Because it makes the interface more complex, these workarounds are not suitable for pushing upstream to optparse-applicative.

Synopsis

- addCommand :: String -> String -> String -> (a -> b) -> Parser c -> Parser a -> EitherT b (Writer (Mod CommandFields (b, c))) ()
- addSubCommands :: Monoid c => String -> String -> String -> Parser c -> EitherT b (Writer (Mod CommandFields (b, c))) () -> EitherT b (Writer (Mod CommandFields (b, c))) ()
- complicatedOptions :: Monoid a => Version -> Maybe String -> String -> String -> String -> String -> Parser a -> Maybe (ParserFailure ParserHelp -> [String] -> IO (a, (b, a))) -> EitherT b (Writer (Mod CommandFields (b, a))) () -> IO (a, b)
- complicatedParser :: Monoid a => Parser a -> EitherT b (Writer (Mod CommandFields (b, a))) () -> Parser (a, (b, a))

# Documentation

addCommand #

Arguments

:: String | command string
-> String | title of command
-> String | footer of command help
-> (a -> b) | constructor to wrap up command in common data type
-> Parser c | common parser
-> Parser a | command parser
-> EitherT b (Writer (Mod CommandFields (b, c))) () |

Add a command to the options dispatcher.

addSubCommands #

Arguments

:: Monoid c |
=> String | command string
-> String | title of command
-> String | footer of command help
-> Parser c | common parser
-> EitherT b (Writer (Mod CommandFields (b, c))) () | sub-commands (use `addCommand`)
-> EitherT b (Writer (Mod CommandFields (b, c))) () |

Add a command that takes sub-commands to the options dispatcher.

complicatedOptions #

Arguments

:: Monoid a |
=> Version | numeric version
-> Maybe String | version string
-> String | hpack numeric version, as string
-> String | header
-> String | program description (displayed between usage and options listing in the help output)
-> String | footer
-> Parser a | common settings
-> Maybe (ParserFailure ParserHelp -> [String] -> IO (a, (b, a))) | optional handler for parser failure; `handleParseResult` is called by default
-> EitherT b (Writer (Mod CommandFields (b, a))) () | commands (use `addCommand`)
-> IO (a, b) |

Generate and execute a complicated options parser.

complicatedParser #

Arguments

:: Monoid a |
=> Parser a | common settings
-> EitherT b (Writer (Mod CommandFields (b, a))) () | commands (use `addCommand`)
-> Parser (a, (b, a)) |

Generate a complicated options parser.