Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 9 additions & 15 deletions cmd/env/add.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ func runEnvAddCommandFunc(clients *shared.ClientFactory, cmd *cobra.Command, arg

// Add the environment variable using either the Slack API method or the
// project ".env" file depending on the app hosting.
var details []string
if hosted && !selection.App.IsDev {
err := clients.API().AddVariable(
ctx,
Expand All @@ -137,14 +138,7 @@ func runEnvAddCommandFunc(clients *shared.ClientFactory, cmd *cobra.Command, arg
if err != nil {
return err
}
clients.IO.PrintTrace(ctx, slacktrace.EnvAddSuccess)
clients.IO.PrintInfo(ctx, false, "\n%s", style.Sectionf(style.TextSection{
Emoji: "evergreen_tree",
Text: "App Environment",
Secondary: []string{
fmt.Sprintf("Successfully added \"%s\" as an app environment variable", variableName),
},
}))
details = append(details, fmt.Sprintf("Successfully added \"%s\" as an app environment variable", variableName))
} else {
exists, err := afero.Exists(clients.Fs, ".env")
if err != nil {
Expand All @@ -154,17 +148,17 @@ func runEnvAddCommandFunc(clients *shared.ClientFactory, cmd *cobra.Command, arg
if err != nil {
return err
}
clients.IO.PrintTrace(ctx, slacktrace.EnvAddSuccess)
var details []string
if !exists {
details = append(details, "Created a project .env file that shouldn't be added to version control")
}
details = append(details, fmt.Sprintf("Successfully added \"%s\" as a project environment variable", variableName))
clients.IO.PrintInfo(ctx, false, "\n%s", style.Sectionf(style.TextSection{
Emoji: "evergreen_tree",
Text: "App Environment",
Secondary: details,
}))
}

clients.IO.PrintTrace(ctx, slacktrace.EnvAddSuccess)
clients.IO.PrintInfo(ctx, false, "\n%s", style.Sectionf(style.TextSection{
Emoji: "evergreen_tree",
Text: "Environment Add",
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question: Based on #460 what about?

  • Set Environment Variable
  • Unset Environment Variable
  • List Environment Variables (plural)
Suggested change
Text: "Environment Add",
Text: "Set Environment Variable",

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mwbrooks Haha I realize these branches overlap! Would we want to use:

  • Environment Set
  • Environment List
  • Environment Unset

Instead? I agree this reads odd but matching the command name might let use expand more in details that follow I hope 📚

Secondary: details,
}))
return nil
}
4 changes: 2 additions & 2 deletions cmd/env/env.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ func NewCommand(clients *shared.ClientFactory) *cobra.Command {
"Add, remove, or list environment variables for the app.",
"",
"Commands that run in the context of a project source environment variables from",
"the \".env\" file. This includes the \"run\" command.",
`the ".env" file. This includes the "run" command.`,
"",
"The \"deploy\" command gathers environment variables from the \".env\" file as well",
`The "deploy" command gathers environment variables from the ".env" file as well`,
"unless the app is using ROSI features.",
"",
`Explore more: {{LinkText "https://docs.slack.dev/tools/slack-cli/guides/using-environment-variables-with-the-slack-cli"}}`,
Expand Down
46 changes: 19 additions & 27 deletions cmd/env/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ func NewEnvListCommand(clients *shared.ClientFactory) *cobra.Command {
"List environment variables available to the app at runtime.",
"",
"Commands that run in the context of a project source environment variables from",
"the \".env\" file. This includes the \"run\" command.",
`the ".env" file. This includes the "run" command.`,
"",
"The \"deploy\" command gathers environment variables from the \".env\" file as well",
`The "deploy" command gathers environment variables from the ".env" file as well`,
"unless the app is using ROSI features.",
}, "\n"),
Example: style.ExampleCommandsf([]style.ExampleCommand{
Expand Down Expand Up @@ -115,36 +115,28 @@ func runEnvListCommandFunc(

count := len(variableNames)
clients.IO.PrintTrace(ctx, slacktrace.EnvListCount, strconv.Itoa(count))
clients.IO.PrintInfo(ctx, false, "\n%s", style.Sectionf(style.TextSection{
Emoji: "evergreen_tree",
Text: "App Environment",
Secondary: []string{
fmt.Sprintf(
"There %s %d %s stored in this environment",
style.Pluralize("is", "are", count),
count,
style.Pluralize("variable", "variables", count),
),
},
}))

if count <= 0 {
return nil
details := []string{
fmt.Sprintf(
"There %s %d %s stored in this environment",
style.Pluralize("is", "are", count),
count,
style.Pluralize("variable", "variables", count),
),
}

sort.Strings(variableNames)
variableLabels := make([]string, 0, count)
for _, v := range variableNames {
variableLabels = append(
variableLabels,
fmt.Sprintf("%s: %s", v, style.Secondary("***")),
)
if count > 0 {
sort.Strings(variableNames)
for _, v := range variableNames {
details = append(details, fmt.Sprintf("- %s: %s", v, style.Secondary("***")))
}
clients.IO.PrintTrace(ctx, slacktrace.EnvListVariables, variableNames...)
}
clients.IO.PrintTrace(ctx, slacktrace.EnvListVariables, variableNames...)
clients.IO.PrintInfo(ctx, false, "%s", style.Sectionf(style.TextSection{

clients.IO.PrintInfo(ctx, false, "\n%s", style.Sectionf(style.TextSection{
Emoji: "evergreen_tree",
Text: "App Environment",
Secondary: variableLabels,
Text: "Environment List",
Secondary: details,
}))

return nil
Expand Down
4 changes: 2 additions & 2 deletions cmd/env/remove.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ func runEnvRemoveCommandFunc(clients *shared.ClientFactory, cmd *cobra.Command,
clients.IO.PrintTrace(ctx, slacktrace.EnvRemoveSuccess)
clients.IO.PrintInfo(ctx, false, "\n%s", style.Sectionf(style.TextSection{
Emoji: "evergreen_tree",
Text: "App Environment",
Text: "Environment Remove",
Comment thread
zimeg marked this conversation as resolved.
Outdated
Secondary: []string{
"The app has no environment variables to remove",
},
Expand Down Expand Up @@ -143,7 +143,7 @@ func runEnvRemoveCommandFunc(clients *shared.ClientFactory, cmd *cobra.Command,
clients.IO.PrintTrace(ctx, slacktrace.EnvRemoveSuccess)
clients.IO.PrintInfo(ctx, false, "\n%s", style.Sectionf(style.TextSection{
Emoji: "evergreen_tree",
Text: "App Environment",
Text: "Environment Remove",
Secondary: []string{
fmt.Sprintf(
"Successfully removed \"%s\" from the app's environment variables",
Expand Down
Loading