Skip to content
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

[WIP] Adding export command to khal CLI #1201

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

hperrey
Copy link

@hperrey hperrey commented Nov 7, 2022

This PR adds an export command to the command line interface of khal. It takes inspiration from PR #839 but uses the same search interface as the 'edit' command. Searches for a specific UID are therefore possible which addresses issue #892. Similarly, dates and date ranges are possible.

Default is output to stdout but output to file is possible via an option. Some examples:

$ ./khal export SC-d8769c25-d1ad-4067-b093-0c35ff5c488e
BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//PIMUTILS.ORG//NONSGML khal / icalendar //EN
BEGIN:VEVENT
SUMMARY:EmacsConf 2022
DTSTART;VALUE=DATE:20221203
DTEND;VALUE=DATE:20221205
DTSTAMP:20220722T191339Z
UID:SC-d8769c25-d1ad-4067-b093-0c35ff5c488e
CATEGORIES:event
END:VEVENT
END:VCALENDAR

Saving instead to file:

$ ./khal export --export-ics khal_export.ics SC-d8769c25-d1ad-4067-b093-0c35ff5c488e
Exported 1 events to output file "khal_export.ics"

This is a WIP as I would like to get some feedback for the approach before going into documentation and tests. I believe that everything discussed in #839 is covered here.

My main concern, however, is handling of repeated events as I am only starting to understand how they work. This approach is not ideal if one specifically wants a given UID: all occurrences of an event are collected before only one is used to retrieve the "raw" ics. From my tests and reading the code, I believe that it does not matter from which of the repeated UIDs I take the raw ics but it would be good to have that confirmed :)

Left to do (from my side):

  • Add documentation
  • Run tests
  • Add tests
  • Add to CHANGELOG.rst
  • Add to AUTHORS.txt

@hperrey hperrey marked this pull request as draft November 7, 2022 10:10
@chr5tphr
Copy link

chr5tphr commented Apr 5, 2023

I also needed this for my workflow.

I wrote a proof of concept CLI script using icalendar instead, in case anyone is interested.

@geier
Copy link
Member

geier commented Apr 29, 2024

Sorry for getting back to you so late and thank you for your interest in khal and making it better.

While I believe this functionally would eventually be a good fit for khal, I would prefer it, if new functionality matures in plugins wherever possible, before we move it into khal itself.

If you are still interested in working on this, please reach out if you need any help or if the plugin API needs to be expanded in some way.

@geier
Copy link
Member

geier commented Apr 29, 2024

And now that I read your name, @hperrey , I rember ghosting you via email a year or two ago. Sorry!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants