New submission from Tom Browder <tom.brow...@gmail.com>:

When I use the argparse module, and I enter my program name with NO arguments 
or options, I would like the argparser to output something like:

Usage: <program name> [options]
Use option '-h' for help.

I haven't yet found how to do that in the argparse module source code, but I do 
that now in my programs by adding this code near the beginning of the program:

# give rudimentary help if nothing but prog name is entered
import os
# get program name as it is called
pnam = os.path.basename(sys.argv[0])
Use = "Usage: {0} [options]".format(pnam)
if len(sys.argv) == 1:
    print(Use)
    print("Use option '-h' for help.")
    sys.exit()

----------
components: Library (Lib)
messages: 114457
nosy: Tom.Browder
priority: normal
severity: normal
status: open
title: New default argparse output to be added
type: feature request
versions: Python 2.7

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue9653>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to