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

Suggestion: Use ANSI Escape Codes Instead of Third-Party Library for Console Colors #432

Open
Praveen005 opened this issue Jun 23, 2024 · 2 comments

Comments

@Praveen005
Copy link
Contributor

Background:

Currently, the CLI uses the github.com/gookit/color library to handle colored output in the console. While this library does its job well, it introduces an additional dependency that might not be necessary.

Suggestion:

I propose replacing the github.com/gookit/color library with ANSI escape codes for coloring text in utility/color_util.go

Here is how the current functions could be rewritten using ANSI escape codes:

color_util.go

@haardikdharma10
Copy link
Contributor

@Praveen005 can you provide an example (possibly a screenshot) of the preview of any existing command by using the color_util.go you provided above

@Praveen005
Copy link
Contributor Author

This is the output with ANSI Codes:

Screenshot 2024-06-26 190625

This is with the present code:

Screenshot 2024-06-26 191353

You would have also noticed that, the first Error is not colored, and the reason is because, It is being directly printed using fmt.Printf()

Likely reason for doing this might be because when we import utility package in config, it leads to circular import.

Screenshot 2024-06-26 192044

But there is a workaround for isolated cases, we can directly use the ANSI code for Red in the string itself, like:

Screenshot 2024-06-26 193410

Result:

Screenshot 2024-06-26 193437

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

No branches or pull requests

2 participants