Skip to content

Commit

Permalink
Small style fixes for notes (#66)
Browse files Browse the repository at this point in the history
  • Loading branch information
keith authored Aug 23, 2023
1 parent 9765de1 commit 91c1d93
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 15 deletions.
14 changes: 10 additions & 4 deletions Sources/RemindersLibrary/CLI.swift
Original file line number Diff line number Diff line change
Expand Up @@ -209,15 +209,21 @@ private struct Edit: ParsableCommand {
help: "The index or id of the reminder to delete, see 'show' for indexes")
var index: String

@Option(
name: .shortAndLong,
help: "The notes to set on the reminder, overwriting previous notes")
var notes: String?

@Argument(
parsing: .remaining,
help: "The new reminder contents")
var reminder: [String] = []

@Option(
name: .shortAndLong,
help: "The new notes")
var notes: String?
func validate() throws {
if self.reminder.isEmpty && self.notes == nil {
throw ValidationError("Must specify either new reminder content or new notes")
}
}

func run() {
let newText = self.reminder.joined(separator: " ")
Expand Down
13 changes: 2 additions & 11 deletions Sources/RemindersLibrary/Reminders.swift
Original file line number Diff line number Diff line change
Expand Up @@ -222,18 +222,9 @@ public final class Reminders {
exit(1)
}

if newText == nil && newNotes == nil {
print("Nothing to update")
exit(1)
}

do {
if let newText = newText {
reminder.title = newText
}
if let newNotes = newNotes {
reminder.notes = newNotes
}
reminder.title = newText ?? reminder.title
reminder.notes = newNotes ?? reminder.notes
try Store.save(reminder, commit: true)
print("Updated reminder '\(reminder.title!)'")
} catch let error {
Expand Down

0 comments on commit 91c1d93

Please sign in to comment.