jrnl icon indicating copy to clipboard operation
jrnl copied to clipboard

Allow --delete and --change-time without confirmation

Open micahellison opened this issue 4 years ago • 5 comments

Feature Request

Use Case/Motivation

The recently-add interactive delete feature (#434) is nice, but it's interactive. It would be nice to have a "force" option (or whatever name is best) if the user wants to delete without being prompted for each entry. It could be particularly useful for scripts/recipes for shuffling data around, perhaps as a resolution to #968 (moving entries).

Example Usage

Maybe --delete-force would be a good name for this option. For instance, deleting the last entry without confirmation:

jrnl --delete-force -n 1

Since there is a good amount of magic in the argument parsing, that might be a more stable solution than adding a new argument on top of the delete like so:

jrnl --delete --force -n 1

micahellison avatar May 30 '20 20:05 micahellison

I think another switch makes most sense (at least in the unix philosophy). Perhaps this force option could void all yesno() prompts? I imagine it wouldn't be too difficult to set a force flag and then have yesno always choose yes if it was true.

Personally, I don't want to work on anything that has to do with the CLI interface because I've read stuff about a new arg parsing mechanism.

eshrh avatar May 30 '20 21:05 eshrh

At the very least, the --delete-force or --delete-yes should come after the filter arguments, similar to jrnl @tag -10 --edit for example.

jrnl -10 --delete -y looks nice and straightforward to me, but I know nothing about the underlying code (or any code, for that matter, since I'm a novice and haven't looked at it yet). In the 5-10 seconds it took to type jrnl -from 2009-01-31 -to 2012-02-03 @tag -starred --delete -y I've probably put an adequate amount of thought into what I intend to do, and I'll be satisfied that jrnl did what I asked it to do. A final "are you really sure" Y is an adequate safeguard, imo.

Another idea, if it hasn't already been mentioned, and if it's possible: jrnl -10 --delete returns a list (short-form) of the entries to be deleted, or a message like "This will delete 132 entries from 1/31/2009 to 2/3/2012, are you sure you want to proceed?" And the choices would be "y/N/i" where i = interactive.

Issue #968 was inspired by a feature in my text editor that selects lines according to some criterion, deletes them from the file but dumps them in a temporary file so I can look them over quickly and make sure it did what I wanted. The --move command could be useful as a behind-the-scenes failsafe for the --delete command.

guydebros avatar May 31 '20 01:05 guydebros

Thanks for the responses! It sounds like having the force behavior as a separate argument makes the most sense. I like the notion that it could operate on a variety of prompts, and it really isn't that normative to have a single "delete-force" argument anyway.

The y/N/i idea is cool too. I'll spin that off to a separate issue.

Let's revisit this as we make progress on the argument parsing.

micahellison avatar Jun 06 '20 18:06 micahellison

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Aug 05 '20 23:08 stale[bot]

A resolution to this issue should affect --change-time as well (#1429).

micahellison avatar May 07 '22 18:05 micahellison