File tree 2 files changed +12
-15
lines changed
2 files changed +12
-15
lines changed Original file line number Diff line number Diff line change @@ -209,15 +209,21 @@ private struct Edit: ParsableCommand {
209
209
help: " The index or id of the reminder to delete, see 'show' for indexes " )
210
210
var index : String
211
211
212
+ @Option (
213
+ name: . shortAndLong,
214
+ help: " The notes to set on the reminder, overwriting previous notes " )
215
+ var notes : String ?
216
+
212
217
@Argument (
213
218
parsing: . remaining,
214
219
help: " The new reminder contents " )
215
220
var reminder : [ String ] = [ ]
216
221
217
- @Option (
218
- name: . shortAndLong,
219
- help: " The new notes " )
220
- var notes : String ?
222
+ func validate( ) throws {
223
+ if self . reminder. isEmpty && self . notes == nil {
224
+ throw ValidationError ( " Must specify either new reminder content or new notes " )
225
+ }
226
+ }
221
227
222
228
func run( ) {
223
229
let newText = self . reminder. joined ( separator: " " )
Original file line number Diff line number Diff line change @@ -222,18 +222,9 @@ public final class Reminders {
222
222
exit ( 1 )
223
223
}
224
224
225
- if newText == nil && newNotes == nil {
226
- print ( " Nothing to update " )
227
- exit ( 1 )
228
- }
229
-
230
225
do {
231
- if let newText = newText {
232
- reminder. title = newText
233
- }
234
- if let newNotes = newNotes {
235
- reminder. notes = newNotes
236
- }
226
+ reminder. title = newText ?? reminder. title
227
+ reminder. notes = newNotes ?? reminder. notes
237
228
try Store . save ( reminder, commit: true )
238
229
print ( " Updated reminder ' \( reminder. title!) ' " )
239
230
} catch let error {
You can’t perform that action at this time.
0 commit comments