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

Add alarms for notifications with due dates #77

Merged
merged 1 commit into from
Feb 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading