-
-
Notifications
You must be signed in to change notification settings - Fork 524
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add --delete for interactive removal of entries #698
Conversation
- Add inquirer dependency for fancy prompting - Fix some minor style issues Fix #434
Turns out the python library I used for prompting doesn't support windows: magmax/python-inquirer#63 I could load an alternative library in that case, disable the feature, or find a different library that works on all platforms. Edit: Pivot to this library: https://github.com/CITGuru/PyInquirer |
# The input for this test is <SPACE><ENTER>y
Scenario: --delete flag allows deletion of single entry
Given we use the config "deletion.yaml"
When we run "jrnl --delete"
And we type " "
And we type
"""
y
"""
When we run "jrnl -on 2019-10-29 -s"
Then the output should not contain "2019-10-29 11:11 First entry." This structure for the test doesn't work... Testing this feature as it is may not be possible. |
PyInquirer seems like a heavy dependency for a relatively simple feature like this. Why don't we just do it like def prompt_delete_entries(entries: List[Entry]):
print("Confirm each entry you want to delete [N/y]:")
to_delete: List[Entry] = []
for entry in entries:
response = input("jrnl: Delete entry '{}'? ".format(entry.pprint(short=True)))
if response == "y":
to_delete.append(entry)
return to_delete And then: jrnl.entries = [e for e in jrnl.entries if e not in to_delete]
jrnl.write() That would also be much easier to test. |
I believe it's a much better user experience with the interactive selection provided by |
jrnl already provides several options to limit your entries: Adding a complete command-line UI just for |
I see a natural progression to using this with I just don't think this looks good, and it's not easy to manage lots of entries with it. Additionally, you can't backstep if you make a mistake. You have to exit and restart the selection process. |
This is a fair point though. I have to take a closer look at how to handle this. |
I may be wrong, but I think the main use case for this would be to delete the last entry. This would be very easy with my proposal, especially when adding a It might even make sense to make that the default when none of the selection options are specified (instead of putting up the whole journal for deletion). Even if you are looking for a specific entry, then you probably saw that entry earlier and can look for it using its date: And then select the one from that day (probably selecting one of 1-5 entries). If you are looking for a specific text to delete in the journal then the feature proposed in #463 would help. But if you need to really scan through the whole thing then maybe just going with Sorry if I'm being a downer here, I'm just personally not a big fan of 'GUIfying' a CLI ;) |
I'd rather combine these steps into one command. Instead of going fishing for an entry, copying the date or a tag or something, and then running
I'm always scared of deleting partial entries / more than I want to when I pull up the raw journal to edit in vim. I always have to scan what I'm deleting multiple times just to be sure... One nice aspect of the interactive selection option is that it's not possible to delete partial entries / corrupt the journal. Your solution works for small lists of entries, but I'd prefer mine for larger lists. I do understand your concerns, however. Still thinking about how to best handle this. It'd be great to get some input from other contributors and users. |
This is a tough one. I think the introduction of an interactive UI is a bit too much for now, but you raise some very good points about how cumbersome it can be to deal with querying large amounts of journal entries for the right ones to delete. I need to think about this one a bit more. @micahellison What do you think? |
I'm of a couple minds about this also. I was about to post that we should use filtering rather than an interactive tool, but then it hit me that one reason to delete an entry could be that a duplicate was made on the same specified time. No amount of filtering could rule out that duplicate, right? Having an entry-by-entry confirmation could deal with that situation, but it could also be really annoying for when a user is really sure that they want to delete a range of entries. And yet, maybe this is what editing is for. After all, people have already been using this tool for seven years, and the edit functionality has been the way to do this. Maybe As an aside, I think there is a place for interactive UIs that interact with jrnl and/or jrnl's data. I would love for this tool to be easily available for people that aren't comfortable with the command line. But I think we should take great care in figuring out their points of contact with jrnl (e.g. a plugin system), and setting them up in a way that minimizes their impact on jrnl's core functionality. So even with tricky use cases like the above, my instinct is to lean away from interactivity. |
I would agree that having a plugin system is probably the right way to go with this. Also, I'm excited to build a plugin system, so there's that :) What if we have filtering with confirmation by default (somewhat along the lines of @pspeter's solution), and offer an interactive deletion plugin. Anyone that doesn't want to use it doesn't have to. |
Yup, sounds good! We can have a |
TODO
|
We can split the |
Yeah, let’s do that.
…On Mon, Dec 16, 2019 at 5:01 PM Jonathan Wren ***@***.***> wrote:
We can split the --force flag into a separate PR, if you'd like.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#698?email_source=notifications&email_token=AE5FN5J6XHUA5GESNEN7VDLQY6Q6FA5CNFSM4JGCR3G2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEG7F4TI#issuecomment-566124109>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AE5FN5PANAVSHQ6YN5ZQ35DQY6Q6FANCNFSM4JGCR3GQ>
.
|
4fa7c94
to
5624544
Compare
@alichtman Hi! This PR still looks really promising. Are you planning on coming back to it? Or would you like someone else to pick it up? |
If someone else could take it from where I left off, that'd be great. I've got a lot on my plate at the moment and can't fit this in, but this feature definitely deserves to get finished. |
@alichtman No worries. Thanks for taking it this far! |
@alichtman Would you be interested in collaborating on a fork of the project? This seems like a really good feature and I'd like to do some more work on it with you |
@dbxnr Hi! As this is an open-source project, you're well within your rights to fork the project and do what you'd like with it. But please don't use our project's space to recruit for--or advertise--your other project. It's distracting for us here, and bad open-source community etiquette. |
@dbxnr, if you're interested in improving this feature, I'd recommend opening another PR (since this one was just merged). |
* Add --delete for interactive removal of entries * Add inquirer dependency for fancy prompting * Fix some minor style issues * Fix jrnl-org#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>
* 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>
* 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>
Fix #434
Checklist