Deprecating options

Martin Pool mbp at canonical.com
Mon Mar 8 01:27:30 GMT 2010


On 6 March 2010 03:55, Alexander Belchenko <bialix at ukr.net> wrote:
> Hi,
>
> today I've decided to deprecated some options in scmproj commands. I did
>  not found any built-in ready-to-use way for this, but I've managed to do
> what I need via custom callback, like this:
>
> def deprecated_option(option, name, new_value, parser):
>    trace.warning('WARNING: Option --%s is deprecated.' %
>        name.replace('_','-'))
>
>
> class cmd_foo(Command):
>
>   takes_options = [Option('bar', hidden=True,
> custom_callback=deprecated_option)]
>
> ...
>
>
> Works fine for me. Maybe something like that will be useful for others
> plugins/core.

That sounds good.  Could you put it up as a proposal for the core?

-- 
Martin <http://launchpad.net/~mbp/>



More information about the bazaar mailing list