diff --git a/jrnl/messages.py b/jrnl/messages.py index b38ff2aa..6b94738f 100644 --- a/jrnl/messages.py +++ b/jrnl/messages.py @@ -110,9 +110,9 @@ class MsgText(Enum): https://github.com/jrnl-org/jrnl/issues/new?title=JournalFailedUpgrade """ - UpgradeAborted = """ - jrnl was NOT upgraded - """ + UpgradeAborted = "jrnl was NOT upgraded" + + ImportAborted = "Entries were NOT imported" # -- Config --- # AltConfigNotFound = """ diff --git a/jrnl/plugins/jrnl_importer.py b/jrnl/plugins/jrnl_importer.py index 214fc70b..54dd2ab8 100644 --- a/jrnl/plugins/jrnl_importer.py +++ b/jrnl/plugins/jrnl_importer.py @@ -4,6 +4,11 @@ import sys +from jrnl.exception import JrnlException +from jrnl.messages import Message +from jrnl.messages import MsgText +from jrnl.messages import MsgType + class JRNLImporter: """This plugin imports entries from other jrnl files.""" @@ -22,8 +27,11 @@ class JRNLImporter: try: other_journal_txt = sys.stdin.read() except KeyboardInterrupt: - print("[Entries NOT imported into journal.]", file=sys.stderr) - sys.exit(0) + raise JrnlException( + Message(MsgText.KeyboardInterruptMsg, MsgType.ERROR), + Message(MsgText.ImportAborted, MsgType.WARNING), + ) + journal.import_(other_journal_txt) new_cnt = len(journal.entries) print(