Use cmd.Name() in cobra commands
authorMikael Berthe <mikael@lilotux.net>
Sun, 23 Apr 2017 22:40:52 +0200
changeset 12 e94c9ed9b1c8
parent 11 3884f5276808
child 13 f862af8faf17
Use cmd.Name() in cobra commands
cmd/accounts.go
--- a/cmd/accounts.go	Sun Apr 23 18:50:09 2017 +0200
+++ b/cmd/accounts.go	Sun Apr 23 22:40:52 2017 +0200
@@ -168,14 +168,14 @@
   madonctl accounts follow-requests --account-id Y --reject`,
 	Short: "List, accept or deny a follow request",
 	RunE: func(cmd *cobra.Command, args []string) error {
-		return accountSubcommandsRunE("follow-requests", args)
+		return accountSubcommandsRunE(cmd.Name(), args)
 	},
 }
 var accountFollowSubcommand = &cobra.Command{
 	Use:   "follow",
 	Short: "Follow or unfollow the account",
 	RunE: func(cmd *cobra.Command, args []string) error {
-		return accountSubcommandsRunE("follow", args)
+		return accountSubcommandsRunE(cmd.Name(), args)
 	},
 }
 
@@ -183,7 +183,7 @@
 	Use:   "block",
 	Short: "Block or unblock the account",
 	RunE: func(cmd *cobra.Command, args []string) error {
-		return accountSubcommandsRunE("block", args)
+		return accountSubcommandsRunE(cmd.Name(), args)
 	},
 }
 
@@ -191,7 +191,7 @@
 	Use:   "mute",
 	Short: "Mute or unmute the account",
 	RunE: func(cmd *cobra.Command, args []string) error {
-		return accountSubcommandsRunE("mute", args)
+		return accountSubcommandsRunE(cmd.Name(), args)
 	},
 }
 
@@ -199,7 +199,7 @@
 	Use:   "relationships --account-ids ACC1,ACC2...",
 	Short: "List relationships with the accounts",
 	RunE: func(cmd *cobra.Command, args []string) error {
-		return accountSubcommandsRunE("relationships", args)
+		return accountSubcommandsRunE(cmd.Name(), args)
 	},
 }
 
@@ -209,7 +209,7 @@
 	Example: `  madonctl accounts reports --list
   madonctl accounts reports --account-id ACCOUNT --status-ids ID... --comment TEXT`,
 	RunE: func(cmd *cobra.Command, args []string) error {
-		return accountSubcommandsRunE("reports", args)
+		return accountSubcommandsRunE(cmd.Name(), args)
 	},
 }