Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Python (http://www.velocityreviews.com/forums/f43-python.html)
-   -   Re: How does one make argparse print usage when no options areprovided on the command line? (http://www.velocityreviews.com/forums/t955153-re-how-does-one-make-argparse-print-usage-when-no-options-areprovided-on-the-command-line.html)

Bruno Dupuis 12-05-2012 05:42 PM

Re: How does one make argparse print usage when no options areprovided on the command line?
 
On Wed, Dec 05, 2012 at 08:48:30AM -0800, rh wrote:
> I have argparse working with one exception. I wanted the program to print out
> usage when no command line options are given. But I only came across
> other examples where people didn't use argparse but instead printed out
> a separate usage statement. So they used argparse for everything but the
> case where no command line args are given.
>


this is quite raw, but i'd add

import sys
if len(sys.argv) == 1:
sys.argv.append('-h')

before I call parser.parse_args()

Should work


--
Bruno Dupuis


All times are GMT. The time now is 10:52 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.