Skip to content

Commit

Permalink
Add opt-in colors to the CLI (#2224)
Browse files Browse the repository at this point in the history
  • Loading branch information
brianstrauch authored Oct 5, 2023
1 parent 29121d1 commit db23990
Show file tree
Hide file tree
Showing 140 changed files with 447 additions and 381 deletions.
4 changes: 4 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ require (
github.com/billgraziano/dpapi v0.4.0
github.com/bradleyjkemp/cupaloy v2.3.0+incompatible
github.com/brianstrauch/cobra-shell v0.4.0
github.com/charmbracelet/lipgloss v0.8.0
github.com/client9/gospell v0.0.0-20160306015952-90dfc71015df
github.com/confluentinc/ccloud-sdk-go-v1-public v0.0.0-20230427001341-5f8d2cce5ad9
github.com/confluentinc/ccloud-sdk-go-v2/apikeys v0.4.0
Expand Down Expand Up @@ -108,6 +109,7 @@ require (
github.com/acomagu/bufpipe v1.0.4 // indirect
github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751 // indirect
github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d // indirect
github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect
github.com/bufbuild/protocompile v0.6.0 // indirect
github.com/c-bata/go-prompt v0.2.6 // indirect
github.com/cenkalti/backoff v2.2.1+incompatible // indirect
Expand Down Expand Up @@ -149,6 +151,8 @@ require (
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/morikuni/aec v1.0.0 // indirect
github.com/muesli/reflow v0.3.0 // indirect
github.com/muesli/termenv v0.15.2 // indirect
github.com/opencontainers/go-digest v1.0.0 // indirect
github.com/opencontainers/runc v1.1.4 // indirect
github.com/pjbgf/sha1cd v0.3.0 // indirect
Expand Down
10 changes: 10 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5 h1:0CwZNZbxp69SHPd
github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5/go.mod h1:wHh0iHkYZB8zMSxRWpUBQtwG5a7fFgvEO+odwuTv2gs=
github.com/aws/aws-sdk-go v1.45.21 h1:9LN2/pMQY2qwGJgSMzv0xNGnstFHCgpSfenvsurX2nk=
github.com/aws/aws-sdk-go v1.45.21/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI=
github.com/aymanbagabas/go-osc52/v2 v2.0.1 h1:HwpRHbFMcZLEVr42D4p7XBqjyuxQH5SMiErDT4WkJ2k=
github.com/aymanbagabas/go-osc52/v2 v2.0.1/go.mod h1:uYgXzlJ7ZpABp8OJ+exZzJJhRNQ2ASbcXHWsFqH8hp8=
github.com/billgraziano/dpapi v0.4.0 h1:t39THI1Ld1hkkLVrhkOX6u5TUxwzRddOffq4jcwh2AE=
github.com/billgraziano/dpapi v0.4.0/go.mod h1:gi1Lin0jvovT53j0EXITkY6UPb3hTfI92POaZgj9JBA=
github.com/bool64/dev v0.2.24 h1:xptlKivPh870W3Xc9szPcM7wkFmTMuHT8rc0nu7dITk=
Expand All @@ -90,6 +92,8 @@ github.com/cenkalti/backoff v2.2.1+incompatible h1:tNowT99t7UNflLxfYYSlKYsBpXdEe
github.com/cenkalti/backoff v2.2.1+incompatible/go.mod h1:90ReRw6GdpyfrHakVjL/QHaoyV4aDUVVkXQJJJ3NXXM=
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
github.com/charmbracelet/lipgloss v0.8.0 h1:IS00fk4XAHcf8uZKc3eHeMUTCxUH6NkaTrdyCQk84RU=
github.com/charmbracelet/lipgloss v0.8.0/go.mod h1:p4eYUZZJ/0oXTuCQKFF8mqyKCz0ja6y+7DniDDw5KKU=
github.com/checkpoint-restore/go-criu/v5 v5.3.0/go.mod h1:E/eQpaFtUKGOOSEBZgmKAcn+zUUwWxqcaKZlF54wK8E=
github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI=
github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI=
Expand Down Expand Up @@ -479,6 +483,7 @@ github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D
github.com/mattn/go-runewidth v0.0.6/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI=
github.com/mattn/go-runewidth v0.0.7/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI=
github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI=
github.com/mattn/go-runewidth v0.0.12/go.mod h1:RAqKPSqVFrSLVXbA8x7dzmKdmGzieGRCM46jaSJTDAk=
github.com/mattn/go-runewidth v0.0.14 h1:+xnbZSEeDbOIg5/mE6JF0w6n9duR1l3/WmbinWVwUuU=
github.com/mattn/go-runewidth v0.0.14/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
github.com/mattn/go-tty v0.0.3/go.mod h1:ihxohKRERHTVzN+aSVRwACLCeqIoZAWpoICkkvrWyR0=
Expand All @@ -498,6 +503,10 @@ github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjY
github.com/morikuni/aec v1.0.0 h1:nP9CBfwrvYnBRgY6qfDQkygYDmYwOilePFkwzv4dU8A=
github.com/morikuni/aec v1.0.0/go.mod h1:BbKIizmSmc5MMPqRYbxO4ZU0S0+P200+tUnFx7PXmsc=
github.com/mrunalp/fileutils v0.5.0/go.mod h1:M1WthSahJixYnrXQl/DFQuteStB1weuxD2QJNHXfbSQ=
github.com/muesli/reflow v0.3.0 h1:IFsN6K9NfGtjeggFP+68I4chLZV2yIKsXJFNZ+eWh6s=
github.com/muesli/reflow v0.3.0/go.mod h1:pbwTDkVPibjO2kyvBQRBxTWEEGDGq0FlB1BIKtnHY/8=
github.com/muesli/termenv v0.15.2 h1:GohcuySI0QmI3wN8Ok9PtKGkgkFIk7y6Vpb5PvrY+Wo=
github.com/muesli/termenv v0.15.2/go.mod h1:Epx+iuz8sNs7mNKhxzH4fWXGNpZwUaJKRS1noLXviQ8=
github.com/munnerz/goautoneg v0.0.0-20120707110453-a547fc61f48d/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ=
github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f/go.mod h1:ZdcZmHo+o7JKHSa8/e818NopupXU1YMK5fe1lsApnBw=
github.com/nrwiersma/avro-benchmarks v0.0.0-20210913175520-21aec48c8f76/go.mod h1:iKyFMidsk/sVYONJRE372sJuX/QTRPacU7imPqqsu7g=
Expand Down Expand Up @@ -542,6 +551,7 @@ github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZN
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
github.com/rivo/tview v0.0.0-20230511053024-822bd067b165 h1:YMycYmUdmLI7ZTn86HUEDM8E8fCMz7twtysBW3SlG0c=
github.com/rivo/tview v0.0.0-20230511053024-822bd067b165/go.mod h1:nVwGv4MP47T0jvlk7KuTTjjuSmrGO4JF0iaiNt4bufE=
github.com/rivo/uniseg v0.1.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
github.com/rivo/uniseg v0.4.3 h1:utMvzDsuh3suAEnhH0RdHmoPbU648o6CvXxTx4SBMOw=
github.com/rivo/uniseg v0.4.3/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
Expand Down
8 changes: 4 additions & 4 deletions internal/admin/command_payment_describe.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,20 +31,20 @@ func (c *command) describe(cmd *cobra.Command, _ []string) error {

marketplace := user.GetOrganization().GetMarketplace()
if marketplace.GetPartner() != ccloudv1.MarketplacePartner_UNKNOWN {
output.Printf("Organization is currently linked to %s Marketplace account.\n", marketplace.GetPartner())
output.Printf(c.Config.EnableColor, "Organization is currently linked to %s Marketplace account.\n", marketplace.GetPartner())
}

if card == nil {
output.Println("No credit card found. Add one using `confluent admin payment update`.")
output.Println(c.Config.EnableColor, "No credit card found. Add one using `confluent admin payment update`.")

ldClient := featureflags.GetCcloudLaunchDarklyClient(c.Context.PlatformName)
if featureflags.Manager.BoolVariation("cloud_growth.marketplace_linking_advertisement_experiment.enable", c.Context, ldClient, true, false) {
output.Println("Alternatively, you can also link to AWS, GCP, or Azure Marketplace as your payment option. For more information, visit https://confluent.cloud/add-payment.")
output.Println(c.Config.EnableColor, "Alternatively, you can also link to AWS, GCP, or Azure Marketplace as your payment option. For more information, visit https://confluent.cloud/add-payment.")
}

return nil
}

output.Printf("%s ending in %s\n", card.GetBrand(), card.GetLast4())
output.Printf(c.Config.EnableColor, "%s ending in %s\n", card.GetBrand(), card.GetLast4())
return nil
}
4 changes: 2 additions & 2 deletions internal/admin/command_payment_update.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ func (c *command) newUpdateCommand() *cobra.Command {
}

func (c *command) update(cmd *cobra.Command, _ []string) error {
output.Println("Edit credit card")
output.Println(c.Config.EnableColor, "Edit credit card")

f := form.New(
form.Field{ID: "card number", Prompt: "Card number", Regex: `^(?:\d[ -]*?){13,19}$`},
Expand All @@ -45,6 +45,6 @@ func (c *command) update(cmd *cobra.Command, _ []string) error {
return err
}

output.Println("Updated.")
output.Println(c.Config.EnableColor, "Updated.")
return nil
}
2 changes: 1 addition & 1 deletion internal/admin/command_promo_add.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@ func (c *command) add(_ *cobra.Command, args []string) error {
return err
}

output.Println("Your promo code was successfully added.")
output.Println(c.Config.EnableColor, "Your promo code was successfully added.")
return nil
}
6 changes: 3 additions & 3 deletions internal/api-key/command_create.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,8 @@ func (c *command) create(cmd *cobra.Command, _ []string) error {
}

if output.GetFormat(cmd) == output.Human {
output.ErrPrintln("It may take a couple of minutes for the API key to be ready.")
output.ErrPrintln("Save the API key and secret. The secret is not retrievable later.")
output.ErrPrintln(c.Config.EnableColor, "It may take a couple of minutes for the API key to be ready.")
output.ErrPrintln(c.Config.EnableColor, "Save the API key and secret. The secret is not retrievable later.")
}

table := output.NewTable(cmd)
Expand Down Expand Up @@ -155,7 +155,7 @@ func (c *command) create(cmd *cobra.Command, _ []string) error {
if err := c.Context.UseAPIKey(userKey.Key, clusterId); err != nil {
return errors.NewWrapErrorWithSuggestions(err, apiKeyUseFailedErrorMsg, fmt.Sprintf(apiKeyUseFailedSuggestions, userKey.Key))
}
output.Printf(useAPIKeyMsg, userKey.Key)
output.Printf(c.Config.EnableColor, useAPIKeyMsg, userKey.Key)
}

return nil
Expand Down
2 changes: 1 addition & 1 deletion internal/api-key/command_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,6 @@ func (c *command) store(cmd *cobra.Command, args []string) error {
return errors.Wrap(err, unableToStoreApiKeyErrorMsg)
}

output.ErrPrintf("Stored secret for API key \"%s\".\n", key)
output.ErrPrintf(c.Config.EnableColor, "Stored secret for API key \"%s\".\n", key)
return nil
}
2 changes: 1 addition & 1 deletion internal/api-key/command_update.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func (c *command) update(cmd *cobra.Command, args []string) error {
return errors.CatchApiKeyForbiddenAccessError(err, updateOperation, httpResp)
}

output.ErrPrintf(errors.UpdateSuccessMsg, "description", "API key", apiKey, description)
output.ErrPrintf(c.Config.EnableColor, errors.UpdateSuccessMsg, "description", "API key", apiKey, description)
}

return nil
Expand Down
2 changes: 1 addition & 1 deletion internal/api-key/command_use.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,6 @@ func (c *command) use(cmd *cobra.Command, args []string) error {
return errors.NewWrapErrorWithSuggestions(err, apiKeyUseFailedErrorMsg, fmt.Sprintf(apiKeyUseFailedSuggestions, args[0]))
}

output.Printf(useAPIKeyMsg, args[0])
output.Printf(c.Config.EnableColor, useAPIKeyMsg, args[0])
return nil
}
4 changes: 2 additions & 2 deletions internal/asyncapi/command_export.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ func (c *command) export(cmd *cobra.Command, _ []string) error {
if err := c.countAsyncApiUsage(accountDetails); err != nil {
log.CliLogger.Debug(err)
}
output.Printf("AsyncAPI specification written to \"%s\".\n", flags.file)
output.Printf(c.Config.EnableColor, "AsyncAPI specification written to \"%s\".\n", flags.file)
return os.WriteFile(flags.file, yaml, 0644)
}

Expand Down Expand Up @@ -205,7 +205,7 @@ func (c *command) getChannelDetails(details *accountDetails, flags *flags) error
log.CliLogger.Warnf("Failed to get subject's compatibility type: %v", err)
}
details.channelDetails.mapOfMessageCompat = mapOfMessageCompat
output.Printf("Added topic \"%s\".\n", details.channelDetails.currentTopic.GetTopicName())
output.Printf(c.Config.EnableColor, "Added topic \"%s\".\n", details.channelDetails.currentTopic.GetTopicName())
return nil
}

Expand Down
16 changes: 8 additions & 8 deletions internal/asyncapi/command_import.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ func (c *command) asyncapiImport(cmd *cobra.Command, args []string) error {
for topicName, topicDetails := range spec.Channels {
if err := c.addChannelToCluster(details, spec, topicName, topicDetails.Bindings.Kafka, flagsImp.overwrite); err != nil {
if err.Error() == parseErrorMessage {
output.Printf("WARNING: topic \"%s\" is already present and `--overwrite` is not set.\n", topicName)
output.Printf(c.Config.EnableColor, "WARNING: topic \"%s\" is already present and `--overwrite` is not set.\n", topicName)
} else {
log.CliLogger.Warn(err)
}
Expand Down Expand Up @@ -242,7 +242,7 @@ func (c *command) addChannelToCluster(details *accountDetails, spec *Spec, topic
spec.Channels[topicName].Description); err != nil {
return fmt.Errorf("unable to update topic description: %v", err)
}
output.Printf("Added description to topic \"%s\".\n", topicName)
output.Printf(c.Config.EnableColor, "Added description to topic \"%s\".\n", topicName)
}
return nil
}
Expand Down Expand Up @@ -298,7 +298,7 @@ func (c *command) createTopic(topicName string, kafkaBinding kafkaBinding) (bool
}
return false, kafkarest.NewError(kafkaRest.CloudClient.GetUrl(), err, httpResp)
}
output.Printf(errors.CreatedResourceMsg, resource.Topic, topicName)
output.Printf(c.Config.EnableColor, errors.CreatedResourceMsg, resource.Topic, topicName)
return true, nil
}

Expand Down Expand Up @@ -335,7 +335,7 @@ func (c *command) updateTopic(topicName string, kafkaBinding kafkaBinding) error
return fmt.Errorf("unable to update topic configs: %v", err)
}
}
output.Printf(errors.UpdatedResourceMsg, resource.Topic, topicName)
output.Printf(c.Config.EnableColor, errors.UpdatedResourceMsg, resource.Topic, topicName)
return nil
}

Expand Down Expand Up @@ -414,7 +414,7 @@ func registerSchema(details *accountDetails, topicName string, components Compon
if err != nil {
return 0, fmt.Errorf("unable to register schema: %v", err)
}
output.Printf("Registered schema \"%d\" under subject \"%s\".\n", id.Id, subject)
output.Printf(false, "Registered schema \"%d\" under subject \"%s\".\n", id.Id, subject)
return id.Id, nil
}
return 0, fmt.Errorf("schema payload not found in YAML input file")
Expand All @@ -428,7 +428,7 @@ func updateSubjectCompatibility(details *accountDetails, compatibility, subject
if err != nil {
return fmt.Errorf("failed to update subject level compatibility: %v", err)
}
output.Printf("Subject level compatibility updated to \"%s\" for subject \"%s\".\n", config.Compatibility, subject)
output.Printf(false, "Subject level compatibility updated to \"%s\" for subject \"%s\".\n", config.Compatibility, subject)
return nil
}

Expand Down Expand Up @@ -466,7 +466,7 @@ func addSchemaTags(details *accountDetails, components Components, topicName str
tag += "s"
}

output.Printf("%s %s added to schema \"%d\".\n", tag, utils.ArrayToCommaDelimitedString(tagNames, "and"), schemaId)
output.Printf(false, "%s %s added to schema \"%d\".\n", tag, utils.ArrayToCommaDelimitedString(tagNames, "and"), schemaId)
}
return nil
}
Expand Down Expand Up @@ -502,7 +502,7 @@ func addTopicTags(details *accountDetails, subscribe Operation, topicName string
tag += "s"
}

output.Printf("%s %s added to Kafka topic \"%s\".\n", tag, utils.ArrayToCommaDelimitedString(tagNames, "and"), topicName)
output.Printf(false, "%s %s added to Kafka topic \"%s\".\n", tag, utils.ArrayToCommaDelimitedString(tagNames, "and"), topicName)
return nil
}

Expand Down
4 changes: 2 additions & 2 deletions internal/audit-log/command_config_migrate.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ func (c *configCommand) migrate(cmd *cobra.Command, _ []string) error {
return err
}
for _, warning := range warnings {
output.ErrPrintln(warning)
output.ErrPrintln()
output.ErrPrintln(c.Config.EnableColor, warning)
output.ErrPrintln(c.Config.EnableColor, "")
}

enc := json.NewEncoder(c.OutOrStdout())
Expand Down
6 changes: 4 additions & 2 deletions internal/byok/command_describe.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,10 @@ func (c *command) outputByokKeyDescription(cmd *cobra.Command, key *byokv1.ByokV
table.Print()

if output.GetFormat(cmd) == output.Human {
output.ErrPrintf("\n%s\n\n", getPostCreateStepInstruction(key))
output.Println(postCreationStepInstructions)
output.ErrPrintln(c.Config.EnableColor, "")
output.ErrPrintf(c.Config.EnableColor, "%s\n", getPostCreateStepInstruction(key))
output.ErrPrintln(c.Config.EnableColor, "")
output.ErrPrintln(c.Config.EnableColor, postCreationStepInstructions)
}

return nil
Expand Down
15 changes: 11 additions & 4 deletions internal/cloud-signup/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,33 @@ import (
"github.com/pkg/browser"
"github.com/spf13/cobra"

pcmd "github.com/confluentinc/cli/v3/pkg/cmd"
"github.com/confluentinc/cli/v3/pkg/errors"
"github.com/confluentinc/cli/v3/pkg/form"
"github.com/confluentinc/cli/v3/pkg/output"
)

func New() *cobra.Command {
type command struct {
*pcmd.CLICommand
}

func New(prerunner pcmd.PreRunner) *cobra.Command {
cmd := &cobra.Command{
Use: "cloud-signup",
Short: "Sign up for Confluent Cloud.",
Args: cobra.NoArgs,
RunE: cloudSignup,
}

c := &command{pcmd.NewAnonymousCLICommand(cmd, prerunner)}
cmd.RunE = c.cloudSignup

return cmd
}

func cloudSignup(cmd *cobra.Command, _ []string) error {
func (c *command) cloudSignup(cmd *cobra.Command, _ []string) error {
signupUrl := "https://www.confluent.io/get-started/"

output.Printf("You will now be redirected to the Confluent Cloud sign up page in your browser. If you are not redirected, please use the following link: %s\n", signupUrl)
output.Printf(c.Config.EnableColor, "You will now be redirected to the Confluent Cloud sign up page in your browser. If you are not redirected, please use the following link: %s\n", signupUrl)
if err := form.ConfirmEnter(); err != nil {
return err
}
Expand Down
5 changes: 3 additions & 2 deletions internal/cluster/command_describe.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,11 @@ func printDescribe(cmd *cobra.Command, meta *ScopedId) error {
}

if meta.ID != "" {
output.Printf("Confluent Resource Name: %s\n\n", meta.ID)
output.Printf(false, "Confluent Resource Name: %s\n", meta.ID)
output.Println(false, "")
}

output.Println("Scope:")
output.Println(false, "Scope:")
list := output.NewList(cmd)
for _, name := range types {
list.Add(&scopeOut{
Expand Down
2 changes: 1 addition & 1 deletion internal/cluster/command_unregister.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,6 @@ func (c *unregisterCommand) unregister(cmd *cobra.Command, _ []string) error {
return cluster.HandleClusterError(err, httpResp)
}

output.Printf("Successfully unregistered cluster \"%s\" from the Cluster Registry.\n", clusterName)
output.Printf(c.Config.EnableColor, "Successfully unregistered cluster \"%s\" from the Cluster Registry.\n", clusterName)
return nil
}
8 changes: 4 additions & 4 deletions internal/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ func NewConfluentCommand(cfg *config.Config) *cobra.Command {
cmd.AddCommand(billing.New(prerunner))
cmd.AddCommand(byok.New(prerunner))
cmd.AddCommand(cluster.New(prerunner, cfg.Version.UserAgent))
cmd.AddCommand(cloudsignup.New())
cmd.AddCommand(cloudsignup.New(prerunner))
cmd.AddCommand(completion.New())
cmd.AddCommand(configuration.New(cfg, prerunner))
cmd.AddCommand(context.New(prerunner, flagResolver))
Expand Down Expand Up @@ -158,7 +158,7 @@ func Execute(cmd *cobra.Command, args []string, cfg *config.Config) error {
}
u := ppanic.CollectPanic(cmd, args, cfg)
if err := reportUsage(cmd, cfg, u); err != nil {
output.ErrPrint(errors.DisplaySuggestionsMessage(err))
output.ErrPrint(cfg.EnableColor, errors.DisplaySuggestionsMessage(err))
}
cobra.CheckErr(r)
}
Expand All @@ -176,9 +176,9 @@ func Execute(cmd *cobra.Command, args []string, cfg *config.Config) error {
}

err := cmd.Execute()
output.ErrPrint(errors.DisplaySuggestionsMessage(err))
u.Error = cliv1.PtrBool(err != nil)
output.ErrPrint(cfg.EnableColor, errors.DisplaySuggestionsMessage(err))

u.Error = cliv1.PtrBool(err != nil)
if err := reportUsage(cmd, cfg, u); err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion internal/completion/completion.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ func New() *cobra.Command {
return err
}

output.Println(out)
output.Println(false, out)
return nil
},
}
Expand Down
4 changes: 2 additions & 2 deletions internal/configuration/command_update.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func (c *command) update(_ *cobra.Command, args []string) error {
if err := c.cfg.Save(); err != nil {
return err
}
output.Print(fmt.Sprintf(errors.UpdateSuccessMsg, "value", "configuration field", field, value))
output.Printf(c.Config.EnableColor, errors.UpdateSuccessMsg, "value", "configuration field", field, value)
return nil
}

Expand Down Expand Up @@ -92,7 +92,7 @@ func confirmSet(field string, prompt form.Prompt) (bool, error) {
return false, err
}
if !f.Responses["proceed"].(bool) {
output.Println(fmt.Sprintf(`Configuration field "%s" was not updated.`, field))
output.Printf(false, "Configuration field \"%s\" was not updated.\n", field)
return false, nil
}
return true, nil
Expand Down
Loading

0 comments on commit db23990

Please sign in to comment.