claw-prettyprinter-0.1.0.0: claw + prettyprinter
Safe HaskellSafe-Inferred
LanguageHaskell2010

System.Console.Options.Help

Description

Pretty-printing functions for composing the help document.

Synopsis

Documentation

name :: Name -> Doc ann Source #

Option name.

>>> putDocW 80 $ name (Short 'h')
-h
>>> putDocW 80 $ name (Long 'long-foo')
--long-foo

option :: Option m (Doc ann) f -> Doc ann Source #

Option together with the argument name, if applicable.

>>> putDocW 80 . option $ Option (Short 'f' :| [Long "foo"]) (plain id)
-f, --foo
>>> putDocW 80 . option $ Option (Long "bar" :| [Long "baz"]) (required "FILE" id)
--bar, --baz=FILE

description Source #

Arguments

:: Int

Base help text indentation

-> Int

Indentation increment

-> Option m (Doc ann) f 
-> Doc ann

Help text

-> Doc ann 

Help description for a given option.

The help text is laid out at base indentation. Additionally the first line of help text can shift based on the increment, in the case that the list of option names is longer than base indentation.

>>> let opt = Option (Short 'f' :| [Long "foo", Long "tediously-long-bar", Long "baz"]) (Flavor (Required "FIL    E") id)
>>> let help = reflow "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor..."
>>> putDocW 80 $ description 32 8 opt help
-f, --foo, --tediously-long-bar, --baz=FILE     Lorem ipsum dolor sit amet,
                                consectetur adipiscing elit, sed do eiusmod
                                tempor...