madonctl accounts mute: Add '--notifications' flag
authorMikael Berthe <mikael@lilotux.net>
Mon, 19 Mar 2018 13:19:36 +0100
changeset 182 842f6cea448f
parent 181 0f3fb2d27ddb
child 183 498d5d188119
madonctl accounts mute: Add '--notifications' flag
cmd/accounts.go
--- a/cmd/accounts.go	Mon Mar 19 11:47:29 2018 +0100
+++ b/cmd/accounts.go	Mon Mar 19 13:19:36 2018 +0100
@@ -34,9 +34,10 @@
 	displayName, note     string // For account update
 	avatar, header        string // For account update
 	locked                bool   // For account update
+	muteNotifications     bool   // For account mute
 }
 
-var accountUpdateFlags *flag.FlagSet
+var accountUpdateFlags, accountMuteFlags *flag.FlagSet
 
 func init() {
 	RootCmd.AddCommand(accountsCmd)
@@ -64,6 +65,7 @@
 
 	accountBlockSubcommand.Flags().BoolVarP(&accountsOpts.unset, "unset", "", false, "Unblock the account")
 	accountMuteSubcommand.Flags().BoolVarP(&accountsOpts.unset, "unset", "", false, "Unmute the account")
+	accountMuteSubcommand.Flags().BoolVarP(&accountsOpts.muteNotifications, "notifications", "", true, "Mute the notifications")
 	accountFollowSubcommand.Flags().BoolVarP(&accountsOpts.unset, "unset", "", false, "Unfollow the account")
 	accountFollowSubcommand.Flags().StringVarP(&accountsOpts.remoteUID, "remote", "r", "", "Follow remote account (user@domain)")
 
@@ -81,6 +83,7 @@
 
 	// This one will be used to check if the options were explicitly set or not
 	accountUpdateFlags = accountUpdateSubcommand.Flags()
+	accountMuteFlags = accountMuteSubcommand.Flags()
 }
 
 // accountsCmd represents the accounts command
@@ -451,7 +454,11 @@
 		if opt.unset {
 			relationship, err = gClient.UnmuteAccount(opt.accountID)
 		} else {
-			relationship, err = gClient.MuteAccount(opt.accountID)
+			var muteNotif *bool
+			if accountMuteFlags.Lookup("notifications").Changed {
+				muteNotif = &opt.muteNotifications
+			}
+			relationship, err = gClient.MuteAccount(opt.accountID, muteNotif)
 		}
 		obj = relationship
 	case "favourites":