mirror of
https://github.com/jrnl-org/jrnl.git
synced 2025-07-03 07:16:12 +02:00
Implement --change-time flag (#1452)
* Implement --change-time flag * Remove todo from --change-time bdd folder journal tests * Add warning when --change-time used with no matching entries * Add a test to make sure running --change-time with nothing prints a warning and doesn't change anything * Add prompt for --change-time * Don't prompt for --change-time when used with --edit and only one entry * When using --edit and --change-time, change the time before editing * Add test for --change-time used with --edit * Modify failing --change-time test to conform to text in develop branch
This commit is contained in:
parent
e6ed64ac7a
commit
33c9dce80d
8 changed files with 342 additions and 12 deletions
|
@ -261,23 +261,29 @@ class Journal:
|
|||
for entry in entries_to_delete:
|
||||
self.entries.remove(entry)
|
||||
|
||||
def prompt_delete_entries(self):
|
||||
"""Prompts for deletion of each of the entries in a journal.
|
||||
Returns the entries the user wishes to delete."""
|
||||
def change_date_entries(self, date):
|
||||
"""Changes entry dates to given date."""
|
||||
date = time.parse(date)
|
||||
|
||||
to_delete = []
|
||||
for entry in self.entries:
|
||||
entry.date = date
|
||||
|
||||
def ask_delete(entry):
|
||||
def prompt_action_entries(self, message):
|
||||
"""Prompts for action for each entry in a journal, using given message.
|
||||
Returns the entries the user wishes to apply the action on."""
|
||||
to_act = []
|
||||
|
||||
def ask_action(entry):
|
||||
return yesno(
|
||||
f"Delete entry '{entry.pprint(short=True)}'?",
|
||||
f"{message} '{entry.pprint(short=True)}'?",
|
||||
default=False,
|
||||
)
|
||||
|
||||
for entry in self.entries:
|
||||
if ask_delete(entry):
|
||||
to_delete.append(entry)
|
||||
if ask_action(entry):
|
||||
to_act.append(entry)
|
||||
|
||||
return to_delete
|
||||
return to_act
|
||||
|
||||
def new_entry(self, raw, date=None, sort=True):
|
||||
"""Constructs a new entry from some raw text input.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue