Negating options

John A Meinel john at arbash-meinel.com
Mon Feb 6 14:05:40 GMT 2006


Denys Duchier wrote:
> 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
> 

This requires that global options occur before the command. People
didn't like this. --quiet, --no-plugins should all be 'global' commands,
and people wanted to type:

bzr selftest --no-plugins

Not just 'bzr --no-plugins selftest'.

The people commenting thought that having pre and post args like cvs was
ugly, and wanted to get rid of it.

So is there another way to have optparse handle this? Does it have
"don't complain about unknown args" so that we can run one pass with the
global option parser, and then run a second pass with the command
specific one?

John
=:->



-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 249 bytes
Desc: OpenPGP digital signature
Url : https://lists.ubuntu.com/archives/bazaar/attachments/20060206/66ceab77/attachment.pgp 


More information about the bazaar mailing list