Add warning when --change-time used with no matching entries

This commit is contained in:
Richard Schneider 2022-04-23 20:54:06 -05:00
parent 14cba37bb9
commit 329d889fc3
3 changed files with 8 additions and 0 deletions

View file

@ -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)

View file

@ -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

View file

@ -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 "<config_file>"
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.