zenlotus / argparse

Automatically exported from code.google.com/p/argparse
Other
0 stars 0 forks source link

convention for reporting program name and version by default #50

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Neither optparse not argparse 1.0.1 provide user friendly reporting of 
program name and version by default.

I propose the following convention to be supported by argument parsing 
library by default.
1. When user calls script.py without arguments the following information is 
displayed
> script.py
Full Program Name, version XXX

Usage: script.py <...>

Short Description

Options:

 ...

> script.py --version
Full Program Name, version XXX
{version template if present with license info or script doc block or ...}

What is the expected output? What do you see instead?
There is `prog` argument to ArgumentParser() that allows to specify script 
name in `"usage: ..."` line, but no argument to specify full program name. 

--version outputs just a number that is not sufficient. In most cases I 
would also like to see revision (as user) or display copyright (as 
developer) or just module docblock that contains both. 

Please provide any additional information below.
It would be nice if argparse could stick to this default output if both 
'version' and 'fullname' information is present and allow to customize 
templates before usage, usage itself, short description and options.

Take a look at 'hg' (or 'svn') command line interface for an example of 
this approach.

Original issue reported on code.google.com by techtonik@gmail.com on 15 Dec 2009 at 1:21

GoogleCodeExporter commented 9 years ago
This is definitely doable, since the output format would only change when the 
new
fullname= argument was supplied. I'll try to add this for the next release, 
though if
you're feeling ambitious, feel free to produce a patch yourself, and I'll 
review it.

Original comment by steven.b...@gmail.com on 15 Dec 2009 at 5:25

GoogleCodeExporter commented 9 years ago
Hmm.  So I looked around, and I can't find an example of this being used in a 
command line program *before* the "usage:". Here's svn:

$ svn help
usage: svn <subcommand> [options] [args]
Subversion command-line client, version 1.6.5.

If it's after "usage:" you can just add it to the description text. It's only 
that if it needs to be before usage that you can't do it with argparse yet.

I'm closing this as WontFix, but if you would really like the ability to add 
text before "usage:" and not just after, please open a new ticket on 
bugs.python.org (argparse's new home), preferably with the output of a couple 
different command line programs that do this so I can see exactly what needs to 
be supported.

Original comment by steven.b...@gmail.com on 23 Jul 2010 at 12:12

GoogleCodeExporter commented 9 years ago
Better take a look at Bazaar and Mercurial. They are potential users of 
argparse.

Original comment by techtonik@gmail.com on 26 Jul 2010 at 2:19

GoogleCodeExporter commented 9 years ago
As I said, please open a new ticket on bugs.python.org. Don't comment on this 
issue here - this tracker is no longer in use.

Original comment by steven.b...@gmail.com on 26 Jul 2010 at 9:55