claw-prettyprinter
Safe HaskellNone
LanguageHaskell2010

Data.Console.Options.Help

Description

Pretty-printing functions for composing the help document.

Synopsis

Documentation

name :: Name -> Doc ann Source #

Option name.

>>> name (Short 'h')
-h
>>> name (Long "long-foo")
--long-foo

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

Option together with the argument name, if applicable.

>>> option $ Option [Short 'f', Long "foo"] Plain
-f, --foo
>>> option $ Option [Long "bar", Long "baz"] (Required "FILE")
--bar, --baz=FILE

description Source #

Arguments

:: Int

Base help text indentation

-> Int

Indentation increment

-> Option (Doc ann) f arg 
-> 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 help = reflow "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor..."
>>> let opt = Option [Long "foo"] Plain
>>> putDocW 80 $ description 32 8 opt help
    --foo                       Lorem ipsum dolor sit amet, consectetur
                                adipiscing elit, sed do eiusmod tempor...
>>> let opt = Option [Short 'f', Long "foo", Long "tediously-long-bar", Long "baz"] (Required "FILE")
>>> 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...