feat: initial implementation of iCalendar to Remind converter
- Add project scaffolding (dune, dune-project, opam, .ocamlformat) - Implement basic parsing and handling of iCalendar events - Add event predicates for common event types (all-day, timed, recurrence, exceptions) - Add transformation logic to map iCalendar events to Remind format (stub implementation) - Provide utilities for extracting event details and converting dates/times - Set up executable entrypoint and command-line interface using Cmdliner - Include Remind event type definitions and helpers
This commit is contained in:
34
bin/main.ml
Normal file
34
bin/main.ml
Normal file
@@ -0,0 +1,34 @@
|
||||
let ical2rem ical_file =
|
||||
let ic = open_in ical_file in
|
||||
let n = in_channel_length ic in
|
||||
let s = Bytes.create n in
|
||||
really_input ic s 0 n;
|
||||
close_in ic;
|
||||
let cal_or_error = Icalendar.parse (Bytes.unsafe_to_string s) in
|
||||
match cal_or_error with
|
||||
| Error e -> prerr_endline ("Error parsing iCalendar file: " ^ e)
|
||||
| Ok (_, components) -> begin
|
||||
let events = ref 0 in
|
||||
List.iter
|
||||
(fun comp ->
|
||||
match comp with
|
||||
| `Event event ->
|
||||
events := !events + 1;
|
||||
let uid = Utils.get_uid event in
|
||||
Printf.printf " ⇒ UID: %s\n" uid;
|
||||
Printf.printf "%s\n\n\n" (Icalendar.show_component comp)
|
||||
| _ -> () (* Ignore non-event components *))
|
||||
components;
|
||||
Printf.printf "\nEvents: %d\n" !events;
|
||||
let events =
|
||||
List.filter_map
|
||||
(function
|
||||
| `Event ev -> Some ev
|
||||
| _ -> None)
|
||||
components
|
||||
in
|
||||
let _reminders = List.map EventTransformer.remind_of_event events in
|
||||
()
|
||||
end
|
||||
|
||||
let () = if !Sys.interactive then () else exit (CommandLine.main ical2rem)
|
||||
Reference in New Issue
Block a user