mirror of
https://github.com/jrnl-org/jrnl.git
synced 2025-06-28 21:46:13 +02:00
Add --delete for interactive removal of entries (#698)
* Add --delete for interactive removal of entries * Add inquirer dependency for fancy prompting * Fix some minor style issues * Fix #434 * Use PyInquirer instead of inquirer for Windows compatibility * Add WIP (broken) test * Change deletion interface to be more basic * Update environment.py Co-authored-by: Jonathan Wren <jonathan@nowandwren.com>
This commit is contained in:
parent
d4a0895163
commit
f4fca3e5a4
5 changed files with 54 additions and 1 deletions
|
@ -234,6 +234,17 @@ class Journal:
|
|||
|
||||
self.entries = result
|
||||
|
||||
def prompt_delete_entries(self):
|
||||
"""Prompts for deletion of entries in a journal."""
|
||||
print("Confirm each entry you want to delete [N/y]:")
|
||||
to_delete: List[Entry] = []
|
||||
for entry in self.entries:
|
||||
response = input("jrnl: Delete entry '{}'? ".format(entry.pprint(short=True)))
|
||||
if response == "y":
|
||||
to_delete.append(entry)
|
||||
|
||||
self.entries = [entry for entry in self.entries if entry not in to_delete]
|
||||
|
||||
def new_entry(self, raw, date=None, sort=True):
|
||||
"""Constructs a new entry from some raw text input.
|
||||
If a date is given, it will parse and use this, otherwise scan for a date in the input first."""
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue