Negating options
Denys Duchier
duchier at ps.uni-sb.de
Sun Feb 5 11:54:39 GMT 2006
On Sat, Feb 04, 2006 at 12:26:50 -0600, John A Meinel wrote:
> As far as using optparse, if we can get it to do what we want "parse
> this set of options, then parse this other set of options once the first
> have been handled, and we have taken the first non-option as a command
> name" I would be happy to use it. My concern is that it doesn't actually
> support our use case very well.
Yes, that is easy to do with optparse:
1. instantiate a parser for global options, and set its
allow_interspersed_args attribute to False.
2. run the parser
3. examine the first remaining arg if any. it should be the name of a
command. use it to extend the parser with command specific options. set
the allow_interspersed_args to True (unless this command also has
subcommands - in which case, leave the allow_interspersed_args to False and
repeat from step 2).
4. run the parser
Cheers,
--Denys
More information about the bazaar
mailing list