LinuxCommandLibrary

help2man

Create man pages from command-line help text

TLDR

Generate a man page for an executable

$ help2man [executable]
copy

Specify the "name" paragraph in the man page
$ help2man [executable] [[-n|--name]] [name]
copy

Specify the section for the man page (defaults to 1)
$ help2man [executable] [[-s|--section]] [section]
copy

Output to a file instead of stdout
$ help2man [executable] [[-o|--output]] [path/to/file]
copy

Display help
$ help2man --help
copy

SYNOPSIS

help2man [ options ] --name 'name string' executable

PARAMETERS

--help
    Display this help message and exit.

--version
    Output version information and exit.

--man-name=name
    Specify the name of the command for the man page. Required parameter.

--output=file
    Write the man page to the specified file instead of standard output.

--locale=locale
    Specify the locale to use when running the program. Useful if the program outputs help text in different languages.

--section=section
    Specify the manual page section (e.g., 1 for user commands, 8 for system administration commands). Defaults to 1.

--no-discard-stderr
    Do not discard stderr output from the command. By default, stderr is discarded.

--include=file
    Include the contents of the specified file in the generated man page, typically used for boilerplate text.

--apropos
    Generate apropos database entries in addition to the man page output.

--source=string
    Specify the source of the command (e.g., 'GNU Coreutils'). Defaults to 'auto'.

DESCRIPTION

help2man generates a simple manual page from the help text of an arbitrary command. It's primarily designed for programs that don't provide their own man pages but offer a '--help' or '-h' option displaying usage information. The command executes the given program with the specified options (usually '--help'), parses the output, and formats it into a basic man page structure suitable for use with man viewers and other documentation tools. The output is typically in the groff format, the standard markup language for man pages. help2man automatically adds standard sections to the generated man page, such as NAME, SYNOPSIS, DESCRIPTION, and SEE ALSO. It aims to quickly create functional man pages for programs that lack proper documentation.

CAVEATS

The quality of the generated man page heavily depends on the quality of the program's help text. If the help text is poorly formatted or incomplete, the resulting man page will also be of low quality. help2man provides only a basic structure; further editing is often necessary to create a polished man page.

EXIT STATUS

help2man returns 0 if successful, and a non-zero value if it encounters an error (e.g., if the program fails to execute or if the 'man-name' option is missing).

ENVIRONMENT VARIABLES

help2man respects standard environment variables like LANG and LC_ALL, which influence the locale used when running the program to retrieve help text.

HISTORY

help2man was created to address the lack of readily available documentation for many command-line programs. It has become a valuable tool for quickly generating man pages where none exist, contributing to better accessibility and understanding of various software tools. Over time it received updates to better parse different help formats and options for customizing the man page generation.

SEE ALSO

man(1), apropos(1), whatis(1)

Copied to clipboard