add new 'NothingToDelete' error to replace old behavior

This commit is contained in:
Jonathan Wren 2022-02-19 16:57:56 -08:00
parent e05257fe47
commit 94feae735e
3 changed files with 9 additions and 5 deletions

View file

@ -53,6 +53,10 @@ class JrnlExceptionMessage(Enum):
https://github.com/jrnl-org/jrnl/issues/new?title=JournalFailedUpgrade https://github.com/jrnl-org/jrnl/issues/new?title=JournalFailedUpgrade
""" """
NothingToDelete = """
No entries to delete, because the search returned no results.
"""
UpgradeAborted = """ UpgradeAborted = """
jrnl was NOT upgraded jrnl was NOT upgraded
""" """

View file

@ -18,6 +18,9 @@ from .exception import UserAbort
from . import time from . import time
from .override import apply_overrides from .override import apply_overrides
from jrnl.exception import JrnlException
from jrnl.exception import JrnlExceptionMessage
def run(args): def run(args):
""" """
@ -310,11 +313,7 @@ def _pluralize_entry(num):
def _delete_search_results(journal, old_entries, **kwargs): def _delete_search_results(journal, old_entries, **kwargs):
if not journal.entries: if not journal.entries:
print( raise JrnlException(JrnlExceptionMessage.NothingToDelete)
"[No entries deleted, because the search returned no results.]",
file=sys.stderr,
)
sys.exit(1)
entries_to_delete = journal.prompt_delete_entries() entries_to_delete = journal.prompt_delete_entries()

View file

@ -41,6 +41,7 @@ Feature: Delete entries from journal
Scenario Outline: Delete flag with nonsense input deletes nothing (issue #932) Scenario Outline: Delete flag with nonsense input deletes nothing (issue #932)
Given we use the config "<config_file>" Given we use the config "<config_file>"
When we run "jrnl --delete asdfasdf" When we run "jrnl --delete asdfasdf"
Then the output should contain "NothingToDelete"
When we run "jrnl -99 --short" When we run "jrnl -99 --short"
Then the output should be Then the output should be
2020-08-29 11:11 Entry the first. 2020-08-29 11:11 Entry the first.