update deprecated_cmd to use new message handling

This commit is contained in:
Jonathan Wren 2022-05-01 09:30:37 -07:00
parent 8da4a991fe
commit 28712132b7
2 changed files with 13 additions and 7 deletions

View file

@ -227,6 +227,12 @@ class MsgText(Enum):
KeyringRetrievalFailure = "Failed to retrieve keyring" KeyringRetrievalFailure = "Failed to retrieve keyring"
# --- Deprecation --- #
DeprecatedCommand = """
The command {old_cmd} is deprecated and will be removed from jrnl soon.
Please use {new_cmd} instead.
"""
class Message(NamedTuple): class Message(NamedTuple):
text: MsgText text: MsgText

View file

@ -19,13 +19,13 @@ from jrnl.messages import MsgText
def deprecated_cmd(old_cmd, new_cmd, callback=None, **kwargs): def deprecated_cmd(old_cmd, new_cmd, callback=None, **kwargs):
warning_msg = f""" print_msg(
The command {old_cmd} is deprecated and will be removed from jrnl soon. Message(
Please use {new_cmd} instead. MsgText.DeprecatedCommand,
""" MsgType.WARNING,
warning_msg = textwrap.dedent(warning_msg) {"old_cmd": old_cmd, "new_cmd": new_cmd},
logging.warning(warning_msg) )
print(f"{WARNING_COLOR}{warning_msg}{RESET_COLOR}", file=sys.stderr) )
if callback is not None: if callback is not None:
callback(**kwargs) callback(**kwargs)