Recommended way for plugin to add an option to an existing command?

Neil Martinsen-Burrell nmb at wartburg.edu
Fri Mar 18 20:32:04 UTC 2011


What is the recommended way to add an option to an existing command
from a plugin?  I know that there are numerous plugins that do this,
and I seem to remember a discussion about wanting to add a standard
way to do so, but I'm not sure what the current state of the art is.
How can I add an option to a command whose value I would like to use
to supplement the behavior of an existing command?

What I would like to do is define a template LogFormatter.  Ideally, I
would do "bzr log --log-format=template --template-str='{revno}
{author}'".  I can define the LogFormatter in my plugin, but I don't
know the right way to inject my option onto the log command.  With the
way that cmd_log works currently, I have to get the value of
template-str and use that to construct an appropriate parametrized
LogFormatter class that can then be passed to the original run()
method of the log command.  What is the right way to add that option?

Any help is welcome.

-Neil



More information about the bazaar mailing list