[RFC] Optparse option handling

Aaron Bentley aaron.bentley at utoronto.ca
Fri Aug 11 14:06:33 BST 2006

Hash: SHA1

John Arbash Meinel wrote:
>> The downside is that the old parameters have been removed, instead of
>> being deprecated.  Supporting looks looks like pain, but if it's felt
>> that we must support e.g. --merge-type as a deprecated option for 0.10,
>> then I will figure out how to support it.
> I'm a little concerned about this. There are 2 parts that I'm worried about.
> 1) compatibility, this doesn't seem hard to fix, even in a limited
> manner that is rather hackish, and then is removed in the next release.

Okay then, I'll make sure all the old switches work, for at least one
release, with deprecation warnings.

> 2) Ability to add new items. Depending on how it is done, this is
> easier/harder. Briefly looking over your code, it seems harder to have a
> plugin provide a new format, and have that be exposed on the command
> line. Because you have hard-coded the possible option in the EnumOption.

> I don't know how hard it would be to read it from some other list, which
> a plugin could keep updated.

I hear you.

Here's what I'm looking at doing:
Create a ChoiceRegistry object.  You would register your options with
the registry like this:

registry.register('long', 'Log formatter that shows merges and stuff',

That would allow plugins to update the list of available formatters, and
ensure that we have all the data about the formatters in one place.

> v- the 'help:usage:' doesn't seem right.

Hmm.  I'm not getting that ouput here.  It may have been a paste error.

> I like the 'aliases:'
> And it would be good to have a similar line for 'plugin:'.

As opposed to '(From plugin "bzrtools")'?

> I assume the word wrapping is because it was wrapped correctly in the
> terminal, but copy & paste messed it up.


> v- This looks incorrectly spaced. 


> I like switching to optparse. Especially if we can use it for global
> options, which are currently rather hackish.

We might be able to, but I think they'll stay hackish, because of our
conflicting desires to allow plugins to modify option lists, and to
allow plugins to be disabled with an option, and to provide aliases, and
to allow aliases to be disabled with an option...

> I actually kind of like 'bzr foo --option=baz' for enumeration options,
> but I may be unique in this. 

It wouldn't be hard to retain --branch-format=foo, (not --format=foo) if
that's desirable.

> I *do* want to make sure we support some
> way for new entries to be added by plugins.

Will do.

Version: GnuPG v1.4.1 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org


More information about the bazaar mailing list