Skip to content

Commit 9116f08

Browse files
committed
docs: add function comments to cmd/api/api.go
1 parent 1e84583 commit 9116f08

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

cmd/api/api.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ type cmdFlags struct {
4343

4444
var flags cmdFlags
4545

46+
// NewCommand returns a new Cobra command for calling Slack API methods
4647
func 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
114116
func 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
217222
func 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
245251
func 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

Comments
 (0)