OptionParser How to: prog <cmd> [options] [arguments]

Gabriel Genellina gagsl-py2 at yahoo.com.ar
Fri Aug 14 05:45:57 EDT 2009


En Fri, 14 Aug 2009 03:22:49 -0300, Steven Woody <narkewoody at gmail.com>  
escribió:

> I am using OptionParser, but I've not managed figure out a way to support
> what I wanted command line format "prog <cmd> [options] [arguments]".
> E.g., "svn ls -r123 http://hello.world".   Can I do this using  
> OptionParser?

Extract the <cmd> yourself, and pass the remaining arguments (that is,  
sys.argv[2:]) to parser.parse_args()

-- 
Gabriel Genellina




More information about the Python-list mailing list