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"
|
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
|
||||||
|
|
|
@ -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)
|
||||||
|
|
Loading…
Add table
Reference in a new issue