Skip to content

Commit ede4c0d

Browse files
authored
Add --notes when adding reminders (#56)
``` reminders add todo some reminder --notes "some notes" ``` It also shows up in `reminders show` Fixes #54
1 parent 75ecc1b commit ede4c0d

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

Sources/RemindersLibrary/CLI.swift

+6
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,15 @@ private struct Add: ParsableCommand {
9090
help: "The priority of the reminder")
9191
var priority: Priority = .none
9292

93+
@Option(
94+
name: .shortAndLong,
95+
help: "The notes to add to the reminder")
96+
var notes: String?
97+
9398
func run() {
9499
reminders.addReminder(
95100
string: self.reminder.joined(separator: " "),
101+
notes: self.notes,
96102
toListNamed: self.listName,
97103
dueDate: self.dueDate,
98104
priority: priority)

Sources/RemindersLibrary/Reminders.swift

+10-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ private func format(_ reminder: EKReminder, at index: Int, listName: String? = n
2020
let dateString = formattedDueDate(from: reminder).map { " (\($0))" } ?? ""
2121
let priorityString = Priority(reminder.mappedPriority).map { " (priority: \($0))" } ?? ""
2222
let listString = listName.map { "\($0): " } ?? ""
23-
return "\(listString)\(index): \(reminder.title ?? "<unknown>")\(dateString)\(priorityString)"
23+
let notesString = reminder.notes.map { " (\($0))" } ?? ""
24+
return "\(listString)\(index): \(reminder.title ?? "<unknown>")\(notesString)\(dateString)\(priorityString)"
2425
}
2526

2627
public enum DisplayOptions: String, Decodable {
@@ -251,11 +252,18 @@ public final class Reminders {
251252
semaphore.wait()
252253
}
253254

254-
func addReminder(string: String, toListNamed name: String, dueDate: DateComponents?, priority: Priority) {
255+
func addReminder(
256+
string: String,
257+
notes: String?,
258+
toListNamed name: String,
259+
dueDate: DateComponents?,
260+
priority: Priority)
261+
{
255262
let calendar = self.calendar(withName: name)
256263
let reminder = EKReminder(eventStore: Store)
257264
reminder.calendar = calendar
258265
reminder.title = string
266+
reminder.notes = notes
259267
reminder.dueDateComponents = dueDate
260268
reminder.priority = Int(priority.value.rawValue)
261269

0 commit comments

Comments
 (0)