Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: use bold rather than backticks around command output #930

Conversation

wyardley
Copy link
Contributor

@wyardley wyardley commented May 4, 2023

Checklist

=========

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have checked for similar issues and haven't found anything relevant.
  • This is not a security issue (which should be reported here: https://circleci.com/security/)
  • I have read Contribution Guidelines.

Internal Checklist

  • I am requesting a review from my own team as well as the owning team
  • I have a plan in place for the monitoring of the changes that I am making (this can include new monitors, logs to be aware of, etc...)

Changes

  • Use color module to bold output of update command error

Rationale

Having backticks in the output of the error when update is disabled doesn't make as much since, since the backticks are rendered literally. Bolding the text probably is better visually.

Considerations

==============

I haven't figured out how to test this easily, or to force fatih/color to send control codes in test mode so that this can be tested.

Screenshots

============

Before

image

After

image

[haven't functionally tested with the exact code, but should look roughly like this]

Here are some helpful tips you can follow when submitting a pull request:

  1. Fork the repository and create your branch from main.
  2. Run make build in the repository root.
  3. If you've fixed a bug or added code that should be tested, add tests!
  4. Ensure the test suite passes (make test).
  5. The --debug flag is often helpful for debugging HTTP client requests and responses.
  6. Format your code with gofmt.
  7. Make sure your code lints (make lint). Note: This requires Docker to run inside a local job.

@wyardley wyardley requested a review from a team as a code owner May 4, 2023 17:45
Use `color` module to bold output of update command error
Tests seem to pass despite not having control codes
@wyardley wyardley force-pushed the wyardley/update-warning-backticks branch from a9b69af to a061e18 Compare May 4, 2023 18:06
@wyardley
Copy link
Contributor Author

wyardley commented May 4, 2023

There's also:

return errors.New("No existing host or token saved.\nThe proper format is `circleci setup --host HOST --token TOKEN --no-prompt")

this is missing the ending backtick anyway / also, but wondering if it would make sense to put the string in double quotes vs. bolding it (also not sure if it would work to bold the error directly?)

Something like (proposed):

diff --git a/cmd/setup.go b/cmd/setup.go
index 6a2d068..c9767b2 100644
--- a/cmd/setup.go
+++ b/cmd/setup.go
@@ -238,7 +238,7 @@ func setupNoPrompt(opts setupOptions) error {
 
 	// Throw an error if both flags are blank are blank!
 	if opts.host == "" && opts.token == "" {
-		return errors.New("No existing host or token saved.\nThe proper format is `circleci setup --host HOST --token TOKEN --no-prompt")
+		return errors.New("No existing host or token saved.\nThe proper format is \"circleci setup --host HOST --token TOKEN --no-prompt\"")
 	}
 
 	config := settings.Config{}

Copy link
Contributor

@JulesFaucherre JulesFaucherre left a comment

Choose a reason for hiding this comment

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

Thanks for this, it is, in fact, much clearer. Your proposition is also interesting!

@JulesFaucherre JulesFaucherre merged commit 5da0619 into CircleCI-Public:develop May 10, 2023
@wyardley wyardley deleted the wyardley/update-warning-backticks branch May 10, 2023 13:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants