What should Python apps do when asked to show help?

Grant Edwards grant.b.edwards at gmail.com
Thu Apr 28 13:33:48 EDT 2016


On 2016-04-28, Steven D'Aprano <steve at pearwood.info> wrote:

> I have an application written in Python which accepts -h or --help to show
> help. I can:
>
> (1) print the help text to stdout;

Yep: just write it to stdout.

> (2) run the help text through a pager;

If you do (1), and I can do that myself if that's what I want.

> (3) do something else?

Nope (at least not by default).

> Many command line tools simply output help to stdout (or stderr, if
> they're evil),

Yep, writing help output to stderr is annoying.

> which makes it easy to redirect the help to a file, pass it to grep,
> etc.

Exactly.

> but I was thinking of doing both: give my application a subcommand or an
> option to display help directly in a pager, while -h and --help print to
> stdout as normal.
>
> What do you think? Too clever?

As long as -? -h --help just write stuff to stdout you can add
whatever other options you like that run pagers, start up web
browsers, or show mp4 movies on the wall without annoying grouchy old
Unix users like me.  ;)

-- 
Grant Edwards               grant.b.edwards        Yow! FOOLED you!  Absorb
                                  at               EGO SHATTERING impulse
                              gmail.com            rays, polyester poltroon!!




More information about the Python-list mailing list