diff --git a/cmd/env/add.go b/cmd/env/add.go index 8ca04424..cea7ae56 100644 --- a/cmd/env/add.go +++ b/cmd/env/add.go @@ -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, @@ -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 { @@ -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", + Secondary: details, + })) return nil } diff --git a/cmd/env/env.go b/cmd/env/env.go index 4a6a929c..915daf6f 100644 --- a/cmd/env/env.go +++ b/cmd/env/env.go @@ -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"}}`, diff --git a/cmd/env/list.go b/cmd/env/list.go index 5f53c7fc..9557e122 100644 --- a/cmd/env/list.go +++ b/cmd/env/list.go @@ -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{ @@ -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 diff --git a/cmd/env/remove.go b/cmd/env/remove.go index 6e161c14..11b2a38d 100644 --- a/cmd/env/remove.go +++ b/cmd/env/remove.go @@ -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", Secondary: []string{ "The app has no environment variables to remove", }, @@ -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",