cmd/notifications.go
changeset 19 4c81f4393773
parent 13 f862af8faf17
child 20 b0ccc09f07a2
--- a/cmd/notifications.go	Fri Apr 28 11:49:22 2017 +0200
+++ b/cmd/notifications.go	Fri Apr 28 13:31:40 2017 +0200
@@ -14,8 +14,8 @@
 )
 
 var notificationsOpts struct {
-	list, clear bool
-	notifID     int
+	list, clear, dismiss bool
+	notifID              int
 }
 
 // notificationsCmd represents the notifications subcommand
@@ -25,6 +25,7 @@
 	Short:   "Manage notifications",
 	Example: `  madonctl accounts notifications --list
   madonctl accounts notifications --list --clear
+  madonctl accounts notifications --dismiss --notification-id N
   madonctl accounts notifications --notification-id N`,
 	//Long:    `TBW...`,
 	RunE: notificationRunE,
@@ -35,6 +36,7 @@
 
 	notificationsCmd.Flags().BoolVar(&notificationsOpts.list, "list", false, "List all current notifications")
 	notificationsCmd.Flags().BoolVar(&notificationsOpts.clear, "clear", false, "Clear all current notifications")
+	notificationsCmd.Flags().BoolVar(&notificationsOpts.dismiss, "dismiss", false, "Delete a notification")
 	notificationsCmd.Flags().IntVar(&notificationsOpts.notifID, "notification-id", 0, "Get a notification")
 }
 
@@ -60,7 +62,11 @@
 		}
 		obj = notifications
 	} else if opt.notifID > 0 {
-		obj, err = gClient.GetNotification(opt.notifID)
+		if opt.dismiss {
+			err = gClient.DismissNotification(opt.notifID)
+		} else {
+			obj, err = gClient.GetNotification(opt.notifID)
+		}
 	}
 
 	if err == nil && opt.clear {