in knack/deprecation.py [0:0]
def __init__(self, cli_ctx=None, object_type='', target=None, redirect=None, hide=False, expiration=None,
tag_func=None, message_func=None, **kwargs):
""" Create a collection of deprecation metadata.
:param cli_ctx: The CLI context associated with the deprecated item.
:type cli_ctx: knack.cli.CLI
:param object_type: A label describing the type of object being deprecated.
:type: object_type: str
:param target: The name of the object being deprecated.
:type target: str
:param redirect: The alternative to redirect users to in lieu of the deprecated item. If omitted it, there is
no alternative.
:type redirect: str
:param hide: A boolean or CLI version at or above-which the deprecated item will no longer appear
in help text, but will continue to work. Warnings will be displayed if the deprecated
item is used.
:type hide: bool OR str
:param expiration: The CLI version at or above-which the deprecated item will no longer work.
:type expiration: str
:param tag_func: Callable which returns the desired unformatted tag string for the deprecated item.
Omit to use the default.
:type tag_func: callable
:param message_func: Callable which returns the desired unformatted message string for the deprecated item.
Omit to use the default.
:type message_func: callable
"""
def _default_get_message(self):
msg = "This {} has been deprecated and will be removed ".format(self.object_type)
if self.expiration:
msg += "in version '{}'.".format(self.expiration)
else:
msg += 'in a future release.'
if self.redirect:
msg += " Use '{}' instead.".format(self.redirect)
return msg
self.redirect = redirect
self.hide = hide
self.expiration = expiration
self._cli_version = cli_ctx.get_cli_version()
super().__init__(
cli_ctx=cli_ctx,
object_type=object_type,
target=target,
color=color_map[_config_key],
tag_func=tag_func or (lambda _: DEFAULT_DEPRECATED_TAG),
message_func=message_func or _default_get_message
)