mirror of
https://github.com/jrnl-org/jrnl.git
synced 2025-05-17 11:38:32 +02:00
update deprecated_cmd to use new message handling
This commit is contained in:
parent
8da4a991fe
commit
28712132b7
2 changed files with 13 additions and 7 deletions
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Add table
Reference in a new issue