Skip to main content

Man Pages for Commands without Man Pages

Project description

moreman: Man Pages for Commands without Man Pages

This program generates man pages for command line tools which do not come with proper separate man pages. For these tools man cannot display manual information, moreman however uses the command's help string (usually displayed via the command line option --help) and assembles from this a "man page".

Overview

moreman is designed as a drop-in replacement for man. Apart from very few options moreman passes all arguments through to the man command it eventually calls. If moreman is called with a tool name for which a normal man page exists, it just passes the name through to man; if no normal man page exists, moreman assembles the man page in the described manner and then calls man for final formatting.

My personal use is inside Emacs: Emacs has the great feature of Man Page Lookup: It displays each man page in its own buffer/frame, so that you easily can view the documentation to a command while using the command in a shell buffer in another window or frame. - And with moreman this extends to all commands which provide some meaningful documentation via their help message even if they do not have a real man page.

A Word of Warning

moreman works by calling the command it wants to create the man page for with the help option - normally --help. This can be dangerous if the command does not expect --help to display the help message.

Installation

Requirements

At least Python 3.5 (legacy Python 2.7 might work as well) plus the argh package.

Install

The tool is pip-installable: pip install moreman For the intended command line use though I recommend installation via pipx:

    pipx install moreman

Usage

Test whether everything is set up correctly by invoking moreman's help message:

$ moreman --help

This should give you something like

usage: moreman [-h] [-v] [--man-cmd MAN_CMD] [-g HELP_ARG] [-f]
               name [name ...]

positional arguments:
  name                  name of the command or man page

optional arguments:
  -h, --help            show this help message and exit
  -v, --verbose         verbose output ('-v' shadows man's -v for version!)
                        (default: False)
  --man-cmd MAN_CMD     man command to be used (default: 'man')
  -g HELP_ARG, --help-arg HELP_ARG
                        help argument to the command used to generate help
                        document (default: '--help')
  -f, --force           force to generate man page from --help even if man
                        page exists ('-f' shadows man's -f for whatis lookup!)
                        (default: False)

All other options are passed through to the 'man' command.

Now try to list the same info as a "man page":

$ moreman moreman

Voila! This should look like a proper man page - many man page viewers are able to recognise this format.[^1]

[^1]: Under the hood moreman creates a nroff file which it passes to man.

Hooking up to Emacs

In order use moreman in Emacs, customise the Emacs variable manual-program (which is in the man customisation group). After checking that you can access moreman from your shell prompt set manual-program to moremanand everything should work fine.

Help for sub commands

Some tools provide extensive help and they split it over the help messages of multiple sub commands. moreman can utilise these sub command help messages via the --help-arg option.

Update September 2019: Some pip installations do install a man page - in that case this example is obsolete.

For example pip --help lists only some general options and pip's sub commands; detailed info about, say, the install sub command is displayed only by pip install --help.

But issue

moreman --help-arg="install --help" pip 

and you get a "man page" for the install subcommand of pip.

This works in Emacs too: After M-x man enter at the prompt --help-arg="install --help" pip.[^2]

[^2]: In Emacs, in order to enter the required spaces you might need to use the ^Q <space> key combination to circumvent Emacs' auto-complete feature at the prompt.

Miscellaneous

If you have difficulties, open an GitHub issue for your problem. If you made enhancements, please create a pull request.

Also note, this project uses another little module I wrote: ArghEx: Extensions for Argh

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

moreman-0.3.2.tar.gz (19.5 kB view details)

Uploaded Source

Built Distribution

moreman-0.3.2-py2.py3-none-any.whl (19.5 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file moreman-0.3.2.tar.gz.

File metadata

  • Download URL: moreman-0.3.2.tar.gz
  • Upload date:
  • Size: 19.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.4.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.4

File hashes

Hashes for moreman-0.3.2.tar.gz
Algorithm Hash digest
SHA256 c6e43d724c96637deccf858ef3d127ec364efee7845351e8d08b88c12844d0e8
MD5 165b24e332fb4096c17336bc0b1a873c
BLAKE2b-256 8152876f9070bccf7b9637d1e1b2a66c8d08e2301c258594eb25b09fdef014da

See more details on using hashes here.

Provenance

File details

Details for the file moreman-0.3.2-py2.py3-none-any.whl.

File metadata

  • Download URL: moreman-0.3.2-py2.py3-none-any.whl
  • Upload date:
  • Size: 19.5 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.4.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.4

File hashes

Hashes for moreman-0.3.2-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 7f0c85c5377b6dc6453bf1a5237ba6bf57f9705c2eba1e5d83536b159ee6c9a3
MD5 91ec1c559c3a7e3cb0b1dd9d47b2f6b4
BLAKE2b-256 39d08c50ebb1d69e1a7ab349d0306eafbee2cf1f570b39e3611bf022ac05c7e9

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page