| Copyright | (c) Dan Shved 2022 |
|---|---|
| License | BSD-3 |
| Maintainer | danshved@gmail.com |
| Stability | experimental |
| Safe Haskell | Safe-Inferred |
| Language | Haskell2010 |
Options.OptStream.Help
Contents
Description
Synopsis
- data Help
- formatHelp :: Help -> String
- makeHeader :: String -> Help
- makeFooter :: String -> Help
- makeFlagHelp :: [OptionForm] -> String -> Help
- makeParamHelp :: [OptionForm] -> String -> String -> Help
- makeMultiParamHelp :: [OptionForm] -> String -> String -> Help
- makeFreeArgHelp :: String -> String -> Help
- clearHelpHeader :: Help -> Help
- clearHelpFooter :: Help -> Help
- clearHelpTable :: Help -> Help
- sortHelpTable :: Help -> Help
Help objects
Represents help information that could be printed when the user passes
--help on the command line.
A Help object contains three parts, each of which could be empty: a
header, an options table, and a footer. Help objects can be composed
together using <>. That will separately concatenate headers, option
tables, and footers.
formatHelp :: Help -> String Source #
Formats the Help object.
h :: Help h = makeHeader "Usage: program [options] ARG" <> makeFreeArgHelp "ARG" "Positional argument." <> makeFlagHelp ["-f", "--foo"] "A flag." <> makeParamHelp ["-p", "--param"] "VAL" "A parameter." <> makeFooter "Example: program --foo bar"
>>>putStrLn $ formatHelp hUsage: program [options] ARG ARG Positional argument. -f, --foo A flag. -p, --param=VAL A parameter. Example: program --foo bar
Arguments
| :: [OptionForm] | All the flag forms, e.g. |
| -> String | Description. |
| -> Help |
Makes a Help object that contains one row in the options table. This
function is suitable to add Help to a flag, i.e. an option that doesn't
take any additional arguments.
You may pass any number of option forms. However, only the first one of each kind (short and long) will be used.
>>>formatHelp $ makeFlagHelp ["-f", "--foo"] "Description."" -f, --foo Description."
Arguments
| :: [OptionForm] | All parameter forms, e.g. |
| -> String | Metavariable describing the additional argument, e.g.
|
| -> String | Description. |
| -> Help |
Makes a Help object that contains one row in the options table. This
function is suitable to add Help to a parameter, i.e. an option that takes
one additional argument.
You may pass any number of option forms. However, only the first one of each kind (short and long) will be used.
>>>formatHelp $ makeParamHelp ["-i", "--input"] "FILE" "Input file."" -i, --input=FILE Input file."
Arguments
| :: [OptionForm] | All multiparameter forms, e.g. |
| -> String | Free-form description for the additional arguments,
e.g. |
| -> String | Description. |
| -> Help |
Makes a Help object that contains one row in the options table. This
function is suitable to add Help to a multi-parameter, i.e. an option that
takes an arbitrary number of additional arguments.
In practice this behaves almost the same as makeParamHelp, except it
advertises a slightly different syntax for passing additional arguments: as
proper additional arguments, without '='.
You may pass any number of option forms. However, only the first one of each kind (short and long) will be used.
>>>formatHelp $ makeMultiParamHelp ["-n", "--full-name"] "FIRST LAST" "First and last name."" -n, --full-name FIRST LAST First and last name."
Modifiers
clearHelpHeader :: Help -> Help Source #
Clears the header of a Help object. Doesn't affect the options table and
the footer.
clearHelpFooter :: Help -> Help Source #
Clears the footer of a Help object. Doesn't affect the header and the
options table.
clearHelpTable :: Help -> Help Source #
Clears the options table of a Help object. Doesn't affect the header and
the footer.
sortHelpTable :: Help -> Help Source #
Sorts the options table so that:
- Free argument options go first, proper options go second.
- Free arguments are sorted lexicographically by metavariable, then by description.
- Options are sorted lexicographically by short form, then by long form, then by description.