Skip to content

Commit

Permalink
Add alarms for notifications with due dates (#77)
Browse files Browse the repository at this point in the history
I'm surprised this doesn't happen automatically but it seems that this
is how Reminders.app makes notifications work.
  • Loading branch information
keith authored Feb 15, 2024
1 parent 886a6a3 commit 710a498
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
8 changes: 4 additions & 4 deletions Sources/RemindersLibrary/CLI.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ private struct ShowLists: ParsableCommand {
private struct ShowAll: ParsableCommand {
static let configuration = CommandConfiguration(
abstract: "Print all reminders")

@Flag(help: "Show completed items only")
var onlyCompleted = false

Expand All @@ -42,15 +42,15 @@ private struct ShowAll: ParsableCommand {
"Cannot specify both --show-completed and --only-completed")
}
}

func run() {
var displayOptions = DisplayOptions.incomplete
if self.onlyCompleted {
displayOptions = .complete
} else if self.includeCompleted {
displayOptions = .all
}

reminders.showAllReminders(
dueOn: self.dueDate, displayOptions: displayOptions, outputFormat: format)
}
Expand Down Expand Up @@ -151,7 +151,7 @@ private struct Add: ParsableCommand {
string: self.reminder.joined(separator: " "),
notes: self.notes,
toListNamed: self.listName,
dueDate: self.dueDate,
dueDateComponents: self.dueDate,
priority: priority,
outputFormat: format)
}
Expand Down
7 changes: 5 additions & 2 deletions Sources/RemindersLibrary/Reminders.swift
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ public final class Reminders {
string: String,
notes: String?,
toListNamed name: String,
dueDate: DateComponents?,
dueDateComponents: DateComponents?,
priority: Priority,
outputFormat: OutputFormat)
{
Expand All @@ -314,8 +314,11 @@ public final class Reminders {
reminder.calendar = calendar
reminder.title = string
reminder.notes = notes
reminder.dueDateComponents = dueDate
reminder.dueDateComponents = dueDateComponents
reminder.priority = Int(priority.value.rawValue)
if let dueDate = dueDateComponents?.date {
reminder.addAlarm(EKAlarm(absoluteDate: dueDate))
}

do {
try Store.save(reminder, commit: true)
Expand Down

0 comments on commit 710a498

Please sign in to comment.