FEATURE REQ: Make alias for --diff-options
John A Meinel
john at arbash-meinel.com
Wed Sep 14 02:59:39 BST 2005
Jari Aalto wrote:
> John A Meinel <john at arbash-meinel.com> writes:
>
> | > $ bzr diff --diff-options -bwc -C 5
> | >
> |
> | As I may have mentioned. One problem is that the short options are
> | consistent across all commands. So while "-o" makes the most sense to
> | diff as "--diff-options", it might make more sense as "--output" for
> | something else. As the interface settles down, I think we'll see more
> | short options form.
> |
> | In the mean-time, might I recommend this plugin:
> |
> | import bzrlib, bzrlib.builtins
> |
> | class cmd_mydiff(bzrlib.builtins.cmd_diff):
> | def run(self, *args, **kwargs):
> | kwargs['diff_options'] = '-bwu -C 5'
> | super(cmd_mydiff, self).run(*args, **kwargs)
> |
> | bzrlib.commands.register_command(cmd_mydiff)
> |
> | Save the above snippet to ~/.bzr.conf/plugins/somefile.py
> |
> | And then it should be automatically loaded by bzr and allow you to type:
> |
> | bzr mydiff
> |
> | Which should set up all the options that you care about. If you *always*
> | want to use it, you can even name the function "cmd_diff", the namespace
> | prevents it from being confused, and then just a plain "bzr diff" will
> | run with your custom options. (If you do overload "bzr diff", then you
> | can run "bzr --no-plugins diff", or "bzr --builtins diff" to get the
> | original function).
>
> Impressive. I have to digest this for few more moon rounds since I
> know nothing about Python.
Well, you don't have to worry too much about the format. Mostly I just
wrote a plugin which does what you want. The plugin uses some advanced
tricks to handle an arbitrary list of options, and pass them on to
another command. All it really does is override a single parameter to
make sure it is set in a certain way.
The above is a generic template that you can use for any function you
want to overload, and set a default value.
John
=:->
>
> Jari
>
>
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 253 bytes
Desc: OpenPGP digital signature
Url : https://lists.ubuntu.com/archives/bazaar/attachments/20050913/263c80e5/attachment.pgp
More information about the bazaar
mailing list