Add deprecated_option_warning() method to Command

This method factors out a common pattern for handling deprecated
command options.

Change-Id: I8ca8ec76365833cc8a71388e478680f7f8444be0
This commit is contained in:
Dean Troyer 2017-01-04 10:47:36 -06:00
parent c6a3990f1f
commit f999ba25d1

View File

@ -47,6 +47,13 @@ class Command(command.Command):
'to enable this command.')
raise exceptions.CommandError(msg)
def deprecated_option_warning(self, old_option, new_option):
"""Emit a warning for use of a deprecated option"""
self.log.warning(
_("The %(old)s option is deprecated, please use %(new)s instead.")
% {'old': old_option, 'new': new_option}
)
class Lister(Command, lister.Lister):
pass