keith / reminders-cli

A simple CLI for interacting with macOS reminders
MIT License
663 stars 52 forks source link

add new cli command 'export-all' to export reminders as json #53

Closed 0xdevalias closed 1 year ago

0xdevalias commented 1 year ago

This PR adds a new export-all option to the CLI, that will export all reminders in JSON format.

It also has an optional --pretty-print flag (defaults to false)

⇒  swift run reminders export-all --help
Building for debugging...
Build complete! (2.69s)
OVERVIEW: Export all reminders as JSON

USAGE: reminders export-all [--pretty-print]

OPTIONS:
  --pretty-print          Pretty print the JSON data
  -h, --help              Show help information.

The output format is a JSON object, where the keys are the name of the Reminder list, which contains an Array of the Reminder objects. Basically:

{
  "MyList" : [
  ],
  "MyOtherList" : [
  ]
}

There are also some outstanding TODO notes for adding a few more bits of data:

// TODO: error: referencing instance method 'encode(_:forKey:)' on 'Array' requires that 'EKAlarm' conform to 'Encodable'
//   Ref: https://developer.apple.com/documentation/eventkit/ekalarm
// try container.encode(alarms, forKey: .alarms)
// TODO: error: referencing instance method 'encode(_:forKey:)' on 'Array' requires that 'EKRecurrenceRule' conform to 'Encodable'
//   Ref: https://developer.apple.com/documentation/eventkit/ekrecurrencerule
// try container.encode(recurrenceRules, forKey: .recurrenceRules)

Currently I believe completed reminders are filtered out automagically, as I am using:

self.reminders(on: self.getCalendars(), displayOptions: .incomplete)
0xdevalias commented 1 year ago

According to this post, it should be potentially be possible to access the url field since iOS 13:

Kolsha commented 1 year ago

Hi! What is the status of this MR?

0xdevalias commented 1 year ago

since that other one seems stalled I'm fine with going with this one

While I had 'eventual' plans to get back to it, I'd definitely say landing this one sooner is the better choice. Then if I ever do get back around to it, I could just update my PR for whatever the current state of the codebase is at that time.

Originally posted by @0xdevalias in https://github.com/keith/reminders-cli/issues/55#issuecomment-1484444294

keith commented 1 year ago

merged https://github.com/keith/reminders-cli/pull/55/ instead, thanks!