Adding options to commands
Russ Brown
pickscrape at gmail.com
Thu Jun 5 04:27:07 BST 2008
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Martin Pool wrote:
> On Thu, Jun 5, 2008 at 7:20 AM, Russ Brown <pickscrape at gmail.com> wrote:
>> I was just looking at getting the diffstat pluging to add a --stat
>> option to the diff command, and so needed to know how to add options to
>> an existing command.
>>
>> For an example I was pointed at the xml-output plugin, which adds
>> options to a number of builtin commands.
>>
>> Looking at the code, it seems the additional options are added by
>> subclassing the builtin command handler.
>>
>> This made me wonder what happens if more than one plugin wants to add
>> options to the same builtin command. Does this magically work, or is it
>> a limitation of the plugin system?
>
> I don't think it will work if they both subclass the builtin command.
> It seems to me they'd be better off asking for the command currently
> registered under that name (through get_cmd_object) and wrapping that.
> Then they'll wrap each other in whichever order they register. (Of
> course it's possible you'll have some bad interactions if they want to
> do contradictory things but that's a separate issue...)
>
> If this works for you maybe you could add a note on the wiki in
> http://bazaar-vcs.org/WritingPlugins
>
I'm not actually in a situation where I'm finding extensions clashing: I
just thought about it as a potential problem.
I'll have a play and see if I can get it to break, then see if your
method fixes it. I'll update the wiki if it does. :)
- --
Russ.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD8DBQFIR10LhXYlbEtYt2wRAkYGAJ9hxOeaUyAOqQAvEAGl1twKK1BdnwCgqiSr
fdNdd7BqrDMw5hLoNNcCtHw=
=cW4e
-----END PGP SIGNATURE-----
More information about the bazaar
mailing list