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

Eric Siegerman lists08-bzr at davor.org
Sun Mar 20 01:50:49 UTC 2011


On Sat, 2011-03-19 at 14:40 -0500, Neil Martinsen-Burrell wrote:
> Thanks for the pointer to that.  I'll see if I can make that work.

If you document the plugin in "bzr help log" (as opposed to just
in 'bzr help your-plugin-name"), please consider appending your
new text to what's already there, perhaps with some appropriate
separator.  Some other plugins replace the docstring outright
(e.g. bzr-loom does this to the help for "status" and "switch"),
which means that "bzr help extended-command" *only* prints help
for the extension, not for the base command.  Sure, one can do
"bzr --no-plugins help extended-command', but that's kludgy.


> Once #491196 is
> addressed, these can be addressed by the same mechanism,

-1

Besides which, that doesn't make a lot of sense unless you're
reimplementing the existing formats in terms of your new
template-based formatter.


> Aha, if I am going to be adding options and overriding behavior, then
> I can in fact force this syntax "bzr log --template='{revno}
> {author}'".  Thanks for the idea.

True, but "--log-format=template:{revno} {author}" is a bit more
extensible, I think -- from a cognitive and UI-design point of
view, that is.  Making it extensible code-wise would entail
enhancing the core to parse --log-format's value as
"formatter[:formatter-specific-argument-string]", and defining a
standard way to provide the argument string to the formatter
instance.  But that can be done later; for now, you can parse it
in the plugin as a special case.

  - Eric





More information about the bazaar mailing list