equal
deleted
inserted
replaced
8 import ( |
8 import ( |
9 "strings" |
9 "strings" |
10 |
10 |
11 "github.com/pkg/errors" |
11 "github.com/pkg/errors" |
12 "github.com/spf13/cobra" |
12 "github.com/spf13/cobra" |
|
13 flag "github.com/spf13/pflag" |
13 "github.com/spf13/viper" |
14 "github.com/spf13/viper" |
14 |
15 |
15 "github.com/McKael/madon" |
16 "github.com/McKael/madon" |
16 ) |
17 ) |
17 |
18 |
18 // toot is a kind of alias for status post |
19 // toot is a kind of alias for status post |
|
20 |
|
21 var tootAliasFlags *flag.FlagSet |
19 |
22 |
20 func init() { |
23 func init() { |
21 RootCmd.AddCommand(tootAliasCmd) |
24 RootCmd.AddCommand(tootAliasCmd) |
22 |
25 |
23 tootAliasCmd.Flags().BoolVar(&statusOpts.sensitive, "sensitive", false, "Mark post as sensitive (NSFW)") |
26 tootAliasCmd.Flags().BoolVar(&statusOpts.sensitive, "sensitive", false, "Mark post as sensitive (NSFW)") |
36 annotation[cobra.BashCompCustom] = []string{"__madonctl_visibility"} |
39 annotation[cobra.BashCompCustom] = []string{"__madonctl_visibility"} |
37 |
40 |
38 tootAliasCmd.Flags().Lookup("visibility").Annotations = annotation |
41 tootAliasCmd.Flags().Lookup("visibility").Annotations = annotation |
39 |
42 |
40 // This one will be used to check if the options were explicitly set or not |
43 // This one will be used to check if the options were explicitly set or not |
41 updateFlags = tootAliasCmd.Flags() |
44 tootAliasFlags = tootAliasCmd.Flags() |
42 } |
45 } |
43 |
46 |
44 var tootAliasCmd = &cobra.Command{ |
47 var tootAliasCmd = &cobra.Command{ |
45 Use: "toot", |
48 Use: "toot", |
46 Aliases: []string{"post", "pouet"}, |
49 Aliases: []string{"post", "pouet"}, |
95 } |
98 } |
96 |
99 |
97 if opt.inReplyToID > 0 { |
100 if opt.inReplyToID > 0 { |
98 var initialStatus *madon.Status |
101 var initialStatus *madon.Status |
99 var preserveVis bool |
102 var preserveVis bool |
100 if opt.sameVisibility && !updateFlags.Lookup("visibility").Changed { |
103 if opt.sameVisibility && |
|
104 !tootAliasFlags.Lookup("visibility").Changed && |
|
105 !statusPostFlags.Lookup("visibility").Changed { |
101 // Preserve visibility unless the --visibility flag |
106 // Preserve visibility unless the --visibility flag |
102 // has been used in the command line. |
107 // has been used in the command line. |
103 preserveVis = true |
108 preserveVis = true |
104 } |
109 } |
105 if preserveVis || opt.addMentions { |
110 if preserveVis || opt.addMentions { |