@@ -43,6 +43,7 @@ type cmdFlags struct {
4343
4444var flags cmdFlags
4545
46+ // NewCommand returns a new Cobra command for calling Slack API methods
4647func NewCommand (clients * shared.ClientFactory ) * cobra.Command {
4748 cmd := & cobra.Command {
4849 Use : "api <method> [key=value ...] [flags]" ,
@@ -111,6 +112,7 @@ func NewCommand(clients *shared.ClientFactory) *cobra.Command {
111112 return cmd
112113}
113114
115+ // runAPICommand resolves a token, builds the request body, and sends a raw HTTP request to the Slack API
114116func runAPICommand (cmd * cobra.Command , clients * shared.ClientFactory , args []string ) error {
115117 ctx := cmd .Context ()
116118 method := args [0 ]
@@ -130,6 +132,8 @@ func runAPICommand(cmd *cobra.Command, clients *shared.ClientFactory, args []str
130132 var bodyReader * strings.Reader
131133 var contentType string
132134
135+ // When the token is placed in the request body (form-encoded), clear it so
136+ // RawRequest does not also send it in the Authorization header.
133137 switch {
134138 case flags .json != "" :
135139 contentType = "application/json; charset=utf-8"
@@ -214,6 +218,7 @@ func runAPICommand(cmd *cobra.Command, clients *shared.ClientFactory, args []str
214218 return nil
215219}
216220
221+ // resolveToken determines the API token to use for the request
217222func resolveToken (ctx context.Context , clients * shared.ClientFactory ) (string , error ) {
218223 if clients .Config .TokenFlag != "" {
219224 return clients .Config .TokenFlag , nil
@@ -242,6 +247,7 @@ func resolveToken(ctx context.Context, clients *shared.ClientFactory) (string, e
242247 WithRemediation ("Provide a token with --token, --app, or set SLACK_BOT_TOKEN" )
243248}
244249
250+ // installAndGetBotToken installs the selected app and returns its bot token
245251func installAndGetBotToken (ctx context.Context , clients * shared.ClientFactory , selected prompts.SelectedApp ) (string , error ) {
246252 manifestSource , _ := clients .Config .ProjectConfig .GetManifestSource (ctx )
247253 var slackManifest types.SlackYaml
0 commit comments