Deprecating options

Alexander Belchenko bialix at ukr.net
Fri Mar 5 16:55:09 GMT 2010


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.




More information about the bazaar mailing list