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"
# --- Deprecation --- #
DeprecatedCommand = """
The command {old_cmd} is deprecated and will be removed from jrnl soon.
Please use {new_cmd} instead.
"""
class Message(NamedTuple):
text: MsgText

View file

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