Fix duplicate usage of updateFlags variable name
authorMikael Berthe <mikael@lilotux.net>
Sun, 18 Mar 2018 23:13:55 +0100
changeset 176 7efbbed5cf3c
parent 175 adcead24cdf1
child 177 a4dd67603406
Fix duplicate usage of updateFlags variable name
cmd/status.go
cmd/toot.go
--- a/cmd/status.go	Sat Oct 28 19:48:20 2017 +0000
+++ b/cmd/status.go	Sun Mar 18 23:13:55 2018 +0100
@@ -12,10 +12,13 @@
 
 	"github.com/pkg/errors"
 	"github.com/spf13/cobra"
+	flag "github.com/spf13/pflag"
 
 	"github.com/McKael/madon"
 )
 
+var statusPostFlags *flag.FlagSet
+
 var statusOpts struct {
 	statusID int64
 	unset    bool
@@ -75,7 +78,7 @@
 	statusPostSubcommand.Flags().Lookup("visibility").Annotations = annotation
 
 	// This one will be used to check if the options were explicitly set or not
-	updateFlags = statusPostSubcommand.Flags()
+	statusPostFlags = statusPostSubcommand.Flags()
 }
 
 // statusCmd represents the status command
--- a/cmd/toot.go	Sat Oct 28 19:48:20 2017 +0000
+++ b/cmd/toot.go	Sun Mar 18 23:13:55 2018 +0100
@@ -10,6 +10,7 @@
 
 	"github.com/pkg/errors"
 	"github.com/spf13/cobra"
+	flag "github.com/spf13/pflag"
 	"github.com/spf13/viper"
 
 	"github.com/McKael/madon"
@@ -17,6 +18,8 @@
 
 // toot is a kind of alias for status post
 
+var tootAliasFlags *flag.FlagSet
+
 func init() {
 	RootCmd.AddCommand(tootAliasCmd)
 
@@ -38,7 +41,7 @@
 	tootAliasCmd.Flags().Lookup("visibility").Annotations = annotation
 
 	// This one will be used to check if the options were explicitly set or not
-	updateFlags = tootAliasCmd.Flags()
+	tootAliasFlags = tootAliasCmd.Flags()
 }
 
 var tootAliasCmd = &cobra.Command{
@@ -97,7 +100,9 @@
 	if opt.inReplyToID > 0 {
 		var initialStatus *madon.Status
 		var preserveVis bool
-		if opt.sameVisibility && !updateFlags.Lookup("visibility").Changed {
+		if opt.sameVisibility &&
+			!tootAliasFlags.Lookup("visibility").Changed &&
+			!statusPostFlags.Lookup("visibility").Changed {
 			// Preserve visibility unless the --visibility flag
 			// has been used in the command line.
 			preserveVis = true