Skip to content
Open
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
17 changes: 17 additions & 0 deletions Sources/RemindCore/EventKitStore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,16 @@ public actor RemindersStore {
reminder.priority = draft.priority.eventKitValue
if let dueDate = draft.dueDate {
reminder.dueDateComponents = calendarComponents(from: dueDate)
// Add alarm if urgent flag is set
if draft.urgent {
// Set priority to high for urgent reminders
reminder.priority = 1 // High priority

// Add alarm with sound
let alarm = EKAlarm(absoluteDate: dueDate)
alarm.soundName = "Alarm" // System alarm sound
reminder.addAlarm(alarm)
}
}
try eventStore.save(reminder, commit: true)
return ReminderItem(
Expand All @@ -112,6 +122,7 @@ public actor RemindersStore {
completionDate: reminder.completionDate,
priority: ReminderPriority(eventKitValue: Int(reminder.priority)),
dueDate: date(from: reminder.dueDateComponents),
hasAlarm: reminder.hasAlarms,
listID: reminder.calendar.calendarIdentifier,
listName: reminder.calendar.title
)
Expand Down Expand Up @@ -153,6 +164,7 @@ public actor RemindersStore {
completionDate: reminder.completionDate,
priority: ReminderPriority(eventKitValue: Int(reminder.priority)),
dueDate: date(from: reminder.dueDateComponents),
hasAlarm: reminder.hasAlarms,
listID: reminder.calendar.calendarIdentifier,
listName: reminder.calendar.title
)
Expand All @@ -173,6 +185,7 @@ public actor RemindersStore {
completionDate: reminder.completionDate,
priority: ReminderPriority(eventKitValue: Int(reminder.priority)),
dueDate: date(from: reminder.dueDateComponents),
hasAlarm: reminder.hasAlarms,
listID: reminder.calendar.calendarIdentifier,
listName: reminder.calendar.title
)
Expand Down Expand Up @@ -212,6 +225,7 @@ public actor RemindersStore {
let completionDate: Date?
let priority: Int
let dueDateComponents: DateComponents?
let hasAlarm: Bool
let listID: String
let listName: String
}
Expand All @@ -228,6 +242,7 @@ public actor RemindersStore {
completionDate: reminder.completionDate,
priority: Int(reminder.priority),
dueDateComponents: reminder.dueDateComponents,
hasAlarm: reminder.hasAlarms,
listID: reminder.calendar.calendarIdentifier,
listName: reminder.calendar.title
)
Expand All @@ -245,6 +260,7 @@ public actor RemindersStore {
completionDate: data.completionDate,
priority: ReminderPriority(eventKitValue: data.priority),
dueDate: date(from: data.dueDateComponents),
hasAlarm: data.hasAlarm,
listID: data.listID,
listName: data.listName
)
Expand Down Expand Up @@ -284,6 +300,7 @@ public actor RemindersStore {
completionDate: reminder.completionDate,
priority: ReminderPriority(eventKitValue: Int(reminder.priority)),
dueDate: date(from: reminder.dueDateComponents),
hasAlarm: reminder.hasAlarms,
listID: reminder.calendar.calendarIdentifier,
listName: reminder.calendar.title
)
Expand Down
7 changes: 6 additions & 1 deletion Sources/RemindCore/Models.swift
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ public struct ReminderItem: Identifiable, Codable, Sendable, Equatable {
public let completionDate: Date?
public let priority: ReminderPriority
public let dueDate: Date?
public let hasAlarm: Bool
public let listID: String
public let listName: String

Expand All @@ -62,6 +63,7 @@ public struct ReminderItem: Identifiable, Codable, Sendable, Equatable {
completionDate: Date?,
priority: ReminderPriority,
dueDate: Date?,
hasAlarm: Bool = false,
listID: String,
listName: String
) {
Expand All @@ -72,6 +74,7 @@ public struct ReminderItem: Identifiable, Codable, Sendable, Equatable {
self.completionDate = completionDate
self.priority = priority
self.dueDate = dueDate
self.hasAlarm = hasAlarm
self.listID = listID
self.listName = listName
}
Expand All @@ -82,12 +85,14 @@ public struct ReminderDraft: Sendable {
public let notes: String?
public let dueDate: Date?
public let priority: ReminderPriority
public let urgent: Bool

public init(title: String, notes: String?, dueDate: Date?, priority: ReminderPriority) {
public init(title: String, notes: String?, dueDate: Date?, priority: ReminderPriority, urgent: Bool = false) {
self.title = title
self.notes = notes
self.dueDate = dueDate
self.priority = priority
self.urgent = urgent
}
}

Expand Down
12 changes: 11 additions & 1 deletion Sources/remindctl/Commands/AddCommand.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,17 @@ enum AddCommand {
help: "none|low|medium|high",
parsing: .singleValue
),
],
flags: [
.make(label: "urgent", names: [.short("u"), .long("urgent")], help: "Set alarm at due time (requires --due)"),
]
)
),
usageExamples: [
"remindctl add \"Buy milk\"",
"remindctl add --title \"Call mom\" --list Personal --due tomorrow",
"remindctl add \"Review docs\" --priority high",
"remindctl add \"Meeting\" --due \"2026-02-01 14:00\" --urgent",
]
) { values, runtime in
let titleOption = values.option("title")
Expand All @@ -56,10 +60,16 @@ enum AddCommand {
let notes = values.option("notes")
let dueValue = values.option("due")
let priorityValue = values.option("priority")
let urgent = values.flag("urgent")

let dueDate = try dueValue.map(CommandHelpers.parseDueDate)
let priority = try priorityValue.map(CommandHelpers.parsePriority) ?? .none

// Urgent requires a due date
if urgent && dueDate == nil {
throw RemindCoreError.operationFailed("--urgent requires --due to be set")
}

let store = RemindersStore()
try await store.requestAccess()

Expand All @@ -73,7 +83,7 @@ enum AddCommand {
throw RemindCoreError.operationFailed("No default list found. Specify --list.")
}

let draft = ReminderDraft(title: title, notes: notes, dueDate: dueDate, priority: priority)
let draft = ReminderDraft(title: title, notes: notes, dueDate: dueDate, priority: priority, urgent: urgent)
let reminder = try await store.createReminder(draft, listName: targetList)
OutputRenderer.printReminder(reminder, format: runtime.outputFormat)
}
Expand Down