Skip to content

Commit e396a02

Browse files
authored
Merge branch 'main' into ale-set-icon
2 parents e11c382 + 89d8085 commit e396a02

13 files changed

Lines changed: 210 additions & 197 deletions

File tree

cmd/env/env.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@ func NewCommand(clients *shared.ClientFactory) *cobra.Command {
4040
"Set, unset, or list environment variables for the project.",
4141
"",
4242
"Commands that run in the context of a project source environment variables from",
43-
"the \".env\" file. This includes the \"run\" command.",
43+
`the ".env" file. This includes the "run" command.`,
4444
"",
45-
"The \"deploy\" command gathers environment variables from the \".env\" file as well",
45+
`The "deploy" command gathers environment variables from the ".env" file as well`,
4646
"unless the app is using ROSI features.",
4747
"",
4848
`Explore more: {{LinkText "https://docs.slack.dev/tools/slack-cli/guides/using-environment-variables-with-the-slack-cli"}}`,

cmd/env/list.go

Lines changed: 19 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@ func NewEnvListCommand(clients *shared.ClientFactory) *cobra.Command {
3838
"List the environment variables available to the project.",
3939
"",
4040
"Commands that run in the context of a project source environment variables from",
41-
"the \".env\" file. This includes the \"run\" command.",
41+
`the ".env" file. This includes the "run" command.`,
4242
"",
43-
"The \"deploy\" command gathers environment variables from the \".env\" file as well",
43+
`The "deploy" command gathers environment variables from the ".env" file as well`,
4444
"unless the app is using ROSI features.",
4545
}, "\n"),
4646
Example: style.ExampleCommandsf([]style.ExampleCommand{
@@ -115,36 +115,28 @@ func runEnvListCommandFunc(
115115

116116
count := len(variableNames)
117117
clients.IO.PrintTrace(ctx, slacktrace.EnvListCount, strconv.Itoa(count))
118-
clients.IO.PrintInfo(ctx, false, "\n%s", style.Sectionf(style.TextSection{
119-
Emoji: "evergreen_tree",
120-
Text: "App Environment",
121-
Secondary: []string{
122-
fmt.Sprintf(
123-
"There %s %d %s stored in this environment",
124-
style.Pluralize("is", "are", count),
125-
count,
126-
style.Pluralize("variable", "variables", count),
127-
),
128-
},
129-
}))
130118

131-
if count <= 0 {
132-
return nil
119+
details := []string{
120+
fmt.Sprintf(
121+
"There %s %d %s set in this environment",
122+
style.Pluralize("is", "are", count),
123+
count,
124+
style.Pluralize("variable", "variables", count),
125+
),
133126
}
134127

135-
sort.Strings(variableNames)
136-
variableLabels := make([]string, 0, count)
137-
for _, v := range variableNames {
138-
variableLabels = append(
139-
variableLabels,
140-
fmt.Sprintf("%s: %s", v, style.Secondary("***")),
141-
)
128+
if count > 0 {
129+
sort.Strings(variableNames)
130+
for _, v := range variableNames {
131+
details = append(details, fmt.Sprintf("- %s: %s", v, style.Secondary("***")))
132+
}
133+
clients.IO.PrintTrace(ctx, slacktrace.EnvListVariables, variableNames...)
142134
}
143-
clients.IO.PrintTrace(ctx, slacktrace.EnvListVariables, variableNames...)
144-
clients.IO.PrintInfo(ctx, false, "%s", style.Sectionf(style.TextSection{
135+
136+
clients.IO.PrintInfo(ctx, false, "\n%s", style.Sectionf(style.TextSection{
145137
Emoji: "evergreen_tree",
146-
Text: "App Environment",
147-
Secondary: variableLabels,
138+
Text: "Environment List",
139+
Secondary: details,
148140
}))
149141

150142
return nil

cmd/env/set.go

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ func runEnvSetCommandFunc(clients *shared.ClientFactory, cmd *cobra.Command, arg
127127

128128
// Add the environment variable using either the Slack API method or the
129129
// project ".env" file depending on the app hosting.
130+
var details []string
130131
if hosted && !selection.App.IsDev {
131132
err := clients.API().AddVariable(
132133
ctx,
@@ -138,14 +139,7 @@ func runEnvSetCommandFunc(clients *shared.ClientFactory, cmd *cobra.Command, arg
138139
if err != nil {
139140
return err
140141
}
141-
clients.IO.PrintTrace(ctx, slacktrace.EnvSetSuccess)
142-
clients.IO.PrintInfo(ctx, false, "\n%s", style.Sectionf(style.TextSection{
143-
Emoji: "evergreen_tree",
144-
Text: "App Environment",
145-
Secondary: []string{
146-
fmt.Sprintf("Successfully added \"%s\" as an app environment variable", variableName),
147-
},
148-
}))
142+
details = append(details, fmt.Sprintf("Successfully set \"%s\" as an app environment variable", variableName))
149143
} else {
150144
exists, err := afero.Exists(clients.Fs, ".env")
151145
if err != nil {
@@ -155,17 +149,17 @@ func runEnvSetCommandFunc(clients *shared.ClientFactory, cmd *cobra.Command, arg
155149
if err != nil {
156150
return err
157151
}
158-
clients.IO.PrintTrace(ctx, slacktrace.EnvSetSuccess)
159-
var details []string
160152
if !exists {
161153
details = append(details, "Created a project .env file that shouldn't be added to version control")
162154
}
163-
details = append(details, fmt.Sprintf("Successfully added \"%s\" as a project environment variable", variableName))
164-
clients.IO.PrintInfo(ctx, false, "\n%s", style.Sectionf(style.TextSection{
165-
Emoji: "evergreen_tree",
166-
Text: "App Environment",
167-
Secondary: details,
168-
}))
155+
details = append(details, fmt.Sprintf("Successfully set \"%s\" as a project environment variable", variableName))
169156
}
157+
158+
clients.IO.PrintTrace(ctx, slacktrace.EnvSetSuccess)
159+
clients.IO.PrintInfo(ctx, false, "\n%s", style.Sectionf(style.TextSection{
160+
Emoji: "evergreen_tree",
161+
Text: "Environment Set",
162+
Secondary: details,
163+
}))
170164
return nil
171165
}

cmd/env/unset.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ func runEnvUnsetCommandFunc(clients *shared.ClientFactory, cmd *cobra.Command, a
110110
clients.IO.PrintTrace(ctx, slacktrace.EnvUnsetSuccess)
111111
clients.IO.PrintInfo(ctx, false, "\n%s", style.Sectionf(style.TextSection{
112112
Emoji: "evergreen_tree",
113-
Text: "App Environment",
113+
Text: "Environment Unset",
114114
Secondary: []string{
115115
"The app has no environment variables to remove",
116116
},
@@ -119,7 +119,7 @@ func runEnvUnsetCommandFunc(clients *shared.ClientFactory, cmd *cobra.Command, a
119119
}
120120
selected, err := clients.IO.SelectPrompt(
121121
ctx,
122-
"Select a variable to remove",
122+
"Select a variable to unset",
123123
variables,
124124
iostreams.SelectPromptConfig{
125125
Flag: clients.Config.Flags.Lookup("name"),
@@ -139,7 +139,7 @@ func runEnvUnsetCommandFunc(clients *shared.ClientFactory, cmd *cobra.Command, a
139139
clients.IO.PrintTrace(ctx, slacktrace.EnvUnsetSuccess)
140140
clients.IO.PrintInfo(ctx, false, "\n%s", style.Sectionf(style.TextSection{
141141
Emoji: "evergreen_tree",
142-
Text: "App Environment",
142+
Text: "Environment Unset",
143143
Secondary: []string{
144144
"The project has no environment variables to remove",
145145
},
@@ -153,7 +153,7 @@ func runEnvUnsetCommandFunc(clients *shared.ClientFactory, cmd *cobra.Command, a
153153
sort.Strings(variables)
154154
selected, err := clients.IO.SelectPrompt(
155155
ctx,
156-
"Select a variable to remove",
156+
"Select a variable to unset",
157157
variables,
158158
iostreams.SelectPromptConfig{
159159
Flag: clients.Config.Flags.Lookup("name"),
@@ -181,9 +181,9 @@ func runEnvUnsetCommandFunc(clients *shared.ClientFactory, cmd *cobra.Command, a
181181
clients.IO.PrintTrace(ctx, slacktrace.EnvUnsetSuccess)
182182
clients.IO.PrintInfo(ctx, false, "\n%s", style.Sectionf(style.TextSection{
183183
Emoji: "evergreen_tree",
184-
Text: "App Environment",
184+
Text: "Environment Unset",
185185
Secondary: []string{
186-
fmt.Sprintf("Successfully removed \"%s\" as an app environment variable", variableName),
186+
fmt.Sprintf("Successfully unset \"%s\" as an app environment variable", variableName),
187187
},
188188
}))
189189
} else {
@@ -194,9 +194,9 @@ func runEnvUnsetCommandFunc(clients *shared.ClientFactory, cmd *cobra.Command, a
194194
clients.IO.PrintTrace(ctx, slacktrace.EnvUnsetSuccess)
195195
clients.IO.PrintInfo(ctx, false, "\n%s", style.Sectionf(style.TextSection{
196196
Emoji: "evergreen_tree",
197-
Text: "App Environment",
197+
Text: "Environment Unset",
198198
Secondary: []string{
199-
fmt.Sprintf("Successfully removed \"%s\" as a project environment variable", variableName),
199+
fmt.Sprintf("Successfully unset \"%s\" as a project environment variable", variableName),
200200
},
201201
}))
202202
}

cmd/env/unset_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ func Test_Env_RemoveCommand(t *testing.T) {
127127
cm.IO.On(
128128
"SelectPrompt",
129129
mock.Anything,
130-
"Select a variable to remove",
130+
"Select a variable to unset",
131131
mock.Anything,
132132
iostreams.MatchPromptConfig(iostreams.SelectPromptConfig{
133133
Flag: cm.Config.Flags.Lookup("name"),
@@ -180,7 +180,7 @@ func Test_Env_RemoveCommand(t *testing.T) {
180180
assert.Equal(t, "OTHER=keep\n", string(content))
181181
},
182182
ExpectedStdoutOutputs: []string{
183-
"Successfully removed \"SECRET\" as a project environment variable",
183+
"Successfully unset \"SECRET\" as a project environment variable",
184184
},
185185
},
186186
"remove a variable from the .env file using prompt": {
@@ -198,7 +198,7 @@ func Test_Env_RemoveCommand(t *testing.T) {
198198
cm.IO.On(
199199
"SelectPrompt",
200200
mock.Anything,
201-
"Select a variable to remove",
201+
"Select a variable to unset",
202202
mock.Anything,
203203
iostreams.MatchPromptConfig(iostreams.SelectPromptConfig{
204204
Flag: cm.Config.Flags.Lookup("name"),

cmd/project/create_template.go

Lines changed: 18 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ import (
2121
"time"
2222

2323
"github.com/slackapi/slack-cli/internal/api"
24-
"github.com/slackapi/slack-cli/internal/experiment"
2524
"github.com/slackapi/slack-cli/internal/iostreams"
2625
"github.com/slackapi/slack-cli/internal/pkg/create"
2726
"github.com/slackapi/slack-cli/internal/shared"
@@ -32,53 +31,9 @@ import (
3231
)
3332

3433
// getSelectionOptions returns the app template options for a given category.
35-
func getSelectionOptions(clients *shared.ClientFactory, categoryID string) []promptObject {
36-
if clients.Config.WithExperimentOn(experiment.Templates) {
37-
templatePromptObjects := map[string]([]promptObject){
38-
"slack-cli#getting-started": {
39-
{
40-
Title: fmt.Sprintf("Bolt for JavaScript %s", style.Secondary("Node.js")),
41-
Repository: "slack-samples/bolt-js-starter-template",
42-
},
43-
{
44-
Title: fmt.Sprintf("Bolt for Python %s", style.Secondary("Python")),
45-
Repository: "slack-samples/bolt-python-starter-template",
46-
},
47-
},
48-
"slack-cli#ai-apps": {
49-
{
50-
Title: fmt.Sprintf("Support Agent %s", style.Secondary("Resolve IT support cases")),
51-
Repository: "slack-cli#ai-apps/support-agent",
52-
},
53-
{
54-
Title: fmt.Sprintf("Custom Agent %s", style.Secondary("Start from scratch")),
55-
Repository: "slack-cli#ai-apps/custom-agent",
56-
},
57-
},
58-
"slack-cli#automation-apps": {
59-
{
60-
Title: fmt.Sprintf("Bolt for JavaScript %s", style.Secondary("Node.js")),
61-
Repository: "slack-samples/bolt-js-custom-function-template",
62-
},
63-
{
64-
Title: fmt.Sprintf("Bolt for Python %s", style.Secondary("Python")),
65-
Repository: "slack-samples/bolt-python-custom-function-template",
66-
},
67-
{
68-
Title: fmt.Sprintf("Deno Slack SDK %s", style.Secondary("Deno")),
69-
Repository: "slack-samples/deno-starter-template",
70-
},
71-
},
72-
}
73-
return templatePromptObjects[categoryID]
74-
}
75-
76-
if strings.TrimSpace(categoryID) == "" {
77-
categoryID = "slack-cli#getting-started"
78-
}
79-
34+
func getSelectionOptions(categoryID string) []promptObject {
8035
templatePromptObjects := map[string]([]promptObject){
81-
"slack-cli#getting-started": []promptObject{
36+
"slack-cli#getting-started": {
8237
{
8338
Title: fmt.Sprintf("Bolt for JavaScript %s", style.Secondary("Node.js")),
8439
Repository: "slack-samples/bolt-js-starter-template",
@@ -88,6 +43,16 @@ func getSelectionOptions(clients *shared.ClientFactory, categoryID string) []pro
8843
Repository: "slack-samples/bolt-python-starter-template",
8944
},
9045
},
46+
"slack-cli#ai-apps": {
47+
{
48+
Title: fmt.Sprintf("Support Agent %s", style.Secondary("Resolve IT support cases")),
49+
Repository: "slack-cli#ai-apps/support-agent",
50+
},
51+
{
52+
Title: fmt.Sprintf("Custom Agent %s", style.Secondary("Start from scratch")),
53+
Repository: "slack-cli#ai-apps/custom-agent",
54+
},
55+
},
9156
"slack-cli#automation-apps": {
9257
{
9358
Title: fmt.Sprintf("Bolt for JavaScript %s", style.Secondary("Node.js")),
@@ -102,18 +67,7 @@ func getSelectionOptions(clients *shared.ClientFactory, categoryID string) []pro
10267
Repository: "slack-samples/deno-starter-template",
10368
},
10469
},
105-
"slack-cli#ai-apps": {
106-
{
107-
Title: fmt.Sprintf("Bolt for JavaScript %s", style.Secondary("Node.js")),
108-
Repository: "slack-samples/bolt-js-assistant-template",
109-
},
110-
{
111-
Title: fmt.Sprintf("Bolt for Python %s", style.Secondary("Python")),
112-
Repository: "slack-samples/bolt-python-assistant-template",
113-
},
114-
},
11570
}
116-
11771
return templatePromptObjects[categoryID]
11872
}
11973

@@ -243,14 +197,10 @@ func promptTemplateSelection(cmd *cobra.Command, clients *shared.ClientFactory,
243197

244198
// Prompt for the example template
245199
prompt := "Select a language:"
246-
if clients.Config.WithExperimentOn(experiment.Templates) {
247-
if categoryID == "slack-cli#ai-apps" {
248-
prompt = "Select a template:"
249-
} else {
250-
prompt = "Select a language:"
251-
}
200+
if categoryID == "slack-cli#ai-apps" {
201+
prompt = "Select a template:"
252202
}
253-
options := getSelectionOptions(clients, categoryID)
203+
options := getSelectionOptions(categoryID)
254204
titles := make([]string, len(options))
255205
for i, m := range options {
256206
titles[i] = m.Title
@@ -348,28 +298,18 @@ func listTemplates(ctx context.Context, clients *shared.ClientFactory, categoryS
348298
}
349299

350300
var categories []categoryInfo
351-
if categoryShortcut == "agent" && clients.Config.WithExperimentOn(experiment.Templates) {
301+
if categoryShortcut == "agent" {
352302
categories = []categoryInfo{
353303
{id: "slack-cli#ai-apps/support-agent", name: "Support agent"},
354304
{id: "slack-cli#ai-apps/custom-agent", name: "Custom agent"},
355305
}
356-
} else if categoryShortcut == "agent" {
357-
categories = []categoryInfo{
358-
{id: "slack-cli#ai-apps", name: "AI Agent apps"},
359-
}
360-
} else if clients.Config.WithExperimentOn(experiment.Templates) {
306+
} else {
361307
categories = []categoryInfo{
362308
{id: "slack-cli#getting-started", name: "Getting started"},
363309
{id: "slack-cli#ai-apps/support-agent", name: "Support agent"},
364310
{id: "slack-cli#ai-apps/custom-agent", name: "Custom agent"},
365311
{id: "slack-cli#automation-apps", name: "Automation apps"},
366312
}
367-
} else {
368-
categories = []categoryInfo{
369-
{id: "slack-cli#getting-started", name: "Getting started"},
370-
{id: "slack-cli#ai-apps", name: "AI Agent apps"},
371-
{id: "slack-cli#automation-apps", name: "Automation apps"},
372-
}
373313
}
374314

375315
for _, category := range categories {
@@ -383,7 +323,7 @@ func listTemplates(ctx context.Context, clients *shared.ClientFactory, categoryS
383323
secondary = append(secondary, repo)
384324
}
385325
} else {
386-
for _, tmpl := range getSelectionOptions(clients, category.id) {
326+
for _, tmpl := range getSelectionOptions(category.id) {
387327
secondary = append(secondary, tmpl.Repository)
388328
}
389329
}

0 commit comments

Comments
 (0)