pimutils / khal

:calendar: CLI calendar application
https://lostpackets.de/khal/
MIT License
2.6k stars 200 forks source link

Non-interactive way to delete events? #603

Open oschrenk opened 7 years ago

oschrenk commented 7 years ago

I saw that there was actually an issue #49 to be able to delete events. It got closed since the new edit feature came out. Is there a way to make it non-interactive and have it delete all/first occurrence?

geier commented 7 years ago

No, not at the moment and I'm not sure how that should work. What do exactly mean with non-interactive? khal delete UID and then get queried delete [A]ll, [N]ext instance, or [S]pecific instance?

WhyNotHugo commented 7 years ago

I think the simplest thing is something like:

khal delete 12:00  # Deletes event for today at midday
khal delete 2017-04-05 13:00

The problem is if you have multiple events at the same time.

FWIW, we deal with this in todoman by printing todos with an internal id (an auto-numeric that we assign on-cache), but I think that's an ugly UX for khal.

oschrenk commented 7 years ago

To delete an event I currently have to

$ khal edit "search term"
10.03. 09:30-10.03. 11:00 Event with search term
Edit?  [n]o  [s]ummary  [d]escription  da[t]etime range  re[p]eat  [l]ocation  [c]ategories  [a]larm  [D]elete  [q]uit: D
Delete all occurences of event? [y/N]: y

So currently I have to be at the keyboard, press D and then press y to delete an event. For me that is interactive. A non-interactive way would be where I can issue a command and the event(s) are deleted, without waiting me to give input. The goal for me here is to automate things

I see these options:

  1. What you suggested: Having UIDs (or some other form of id) as part of search results, which in turn I can target with a delete command
  2. Or having a flag/option on the edit command to delete results eg `khal edit --delete "search term".
  3. Having a separate command like khal delete "search term". It could automatically delete all the results it would return and just spit out the result. But it could also offer an interactive version as default, asking for confirmation for each deletion, and then flags like --force for a non-interactive version
bbugyi200 commented 5 years ago

I remember seeing this issue and wanted to provide a quick work around for anyone else who wants this feature as bad as I do. If your instance of khal is using sqlite, you can just write a shell function or two with a oneliner interfacing the sqlite database.

For example, after defining the function below you can use kdel EVENT from the command-line to delete all khal events with summaries that start with EVENT. Be warned that this query will also match events with fields below summary that match EVENT. I'm not sure how to fix that.

kdel() { sqlite3 /home/"${USER}"/.local/share/khal/khal.db < <(echo "DELETE FROM events WHERE item LIKE '%SUMMARY:$1%';"); }