@@ -22,13 +22,19 @@ const (
22
22
specifyAlias = "Please specify alias."
23
23
subscriptionDeleteSuccess = "Subscription with alias **%s** deleted successfully."
24
24
noChannelSubscription = "No subscription found for this channel."
25
+ helpText = "###### Mattermost Confluence Plugin - Slash Command Help\n " +
26
+ "\n * `/confluence subscribe` - Subscribe the current channel to receive notifications from Confluence.\n " +
27
+ "* `/confluence unsubscribe \" <alias>\" ` - Unsubscribe notifications for the current channel for a given subscription alias.\n " +
28
+ "* `/confluence list` - List all subscriptions configured for the current channel.\n " +
29
+ "* `/confluence edit \" <alias>\" ` - Edit the subscribed events for the given subscription alias for the current channel.\n "
25
30
)
26
31
27
32
var ConfluenceCommandHandler = Handler {
28
33
handlers : map [string ]HandlerFunc {
29
34
"list" : listChannelSubscription ,
30
35
"unsubscribe" : deleteSubscription ,
31
36
"edit" : editSubscription ,
37
+ "help" : confluenceHelp ,
32
38
},
33
39
defaultHandler : executeConfluenceDefault ,
34
40
}
@@ -39,16 +45,15 @@ func GetCommand() *model.Command {
39
45
DisplayName : "Confluence" ,
40
46
Description : "Integration with Confluence." ,
41
47
AutoComplete : true ,
42
- AutoCompleteDesc : "Available commands: subscribe, list, unsubscribe \" <alias>\" " ,
48
+ AutoCompleteDesc : "Available commands: subscribe, list, unsubscribe \" <alias>\" , edit \" <alias> \" , help. " ,
43
49
AutoCompleteHint : "[command]" ,
44
50
}
45
51
}
46
52
47
- // TODO : Show help text instead of invalid command.
48
53
func executeConfluenceDefault (context * model.CommandArgs , args ... string ) * model.CommandResponse {
49
54
return & model.CommandResponse {
50
55
ResponseType : model .COMMAND_RESPONSE_TYPE_EPHEMERAL ,
51
- Text : "Invalid command" ,
56
+ Text : "Invalid command parameters. Please use `/confluence help` for more information. " ,
52
57
}
53
58
}
54
59
@@ -62,6 +67,9 @@ func postCommandResponse(context *model.CommandArgs, text string) {
62
67
}
63
68
64
69
func (ch Handler ) Handle (context * model.CommandArgs , args ... string ) * model.CommandResponse {
70
+ if len (args ) == 0 {
71
+ return ch .handlers ["help" ](context , "" )
72
+ }
65
73
for n := len (args ); n > 0 ; n -- {
66
74
h := ch .handlers [strings .Join (args [:n ], "/" )]
67
75
if h != nil {
@@ -112,3 +120,8 @@ func editSubscription(context *model.CommandArgs, args ...string) *model.Command
112
120
}
113
121
return & model.CommandResponse {}
114
122
}
123
+
124
+ func confluenceHelp (context * model.CommandArgs , args ... string ) * model.CommandResponse {
125
+ postCommandResponse (context , helpText )
126
+ return & model.CommandResponse {}
127
+ }
0 commit comments