diff --git a/jrnl/jrnl.py b/jrnl/jrnl.py index 439237c6..43800ddf 100644 --- a/jrnl/jrnl.py +++ b/jrnl/jrnl.py @@ -339,6 +339,9 @@ def _delete_search_results(journal, old_entries, **kwargs): def _change_time_search_results(args, journal, old_entries, **kwargs): + if not journal.entries: + raise JrnlException(Message(MsgText.NothingToModify, MsgType.WARNING)) + # separate entries we are not editing other_entries = _other_entries(journal, old_entries) diff --git a/jrnl/messages.py b/jrnl/messages.py index e6a1933a..7e7bc205 100644 --- a/jrnl/messages.py +++ b/jrnl/messages.py @@ -130,6 +130,10 @@ class MsgText(Enum): No entries to delete, because the search returned no results """ + NothingToModify = """ + No entries to modify, because the search returned no results + """ + class Message(NamedTuple): text: MsgText diff --git a/tests/bdd/features/change_time.feature b/tests/bdd/features/change_time.feature index a4fdb403..3379fe70 100644 --- a/tests/bdd/features/change_time.feature +++ b/tests/bdd/features/change_time.feature @@ -22,6 +22,7 @@ Feature: Change entry times in journal Scenario Outline: Change time flag with nonsense input changes nothing Given we use the config "" When we run "jrnl --change-time now asdfasdf" + Then the output should contain "No entries to modify" When we run "jrnl -99 --short" Then the output should be 2020-08-29 11:11 Entry the first.