Fix: removed usage pick(); Refactored map() usage; moved type property into prefix addition

This commit is contained in:
Ludwig Behm 2023-10-18 17:26:25 +02:00
parent f1a7e0dd42
commit 097eaa0500
Signed by: l.behm
GPG key ID: D344835D63B89384
2 changed files with 13 additions and 10 deletions

View file

@ -1,10 +1,13 @@
#!/usr/bin/jq -rfc
[
(
.[2][] # skipping calender header and accessing events
| [["_type", {}, "text", .[0]], .[1][]] # adding ical type like 'vevent' as ._type property
| [.[] | {"key": .[0], "value": .[3]}] | from_entries # transforming event array structure into object structure
| pick(._type, .dtstart, .dtend, .summary, .location, .description, .sequence, .["related-to"]) # allow list of properties
.[2] # skipping calender header and accessing events
| map( # for each event:
{_type: .[0]} # adding ical type like 'vevent' as ._type property
+ (
.[1] # accessing jCal properties; [1] holds name of iCalendar component, i.e. `vevent`; [2] holds additional components
| map({key: .[0], value: .[3]}) | from_entries # transforming event array structure into object structure
# only tested with vevents. pick() isn't supported in jq on debian bookworm
# | pick(.dtstart, .dtend, .summary, .location, .description, .sequence, .["related-to"]) # allow list of properties
)
]
)
| sort_by(.dtstart|fromdate) # sorting by event start time