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

Disabling terminal output coloring #1893

Closed
tchaumeny opened this issue Jun 23, 2023 · 8 comments
Closed

Disabling terminal output coloring #1893

tchaumeny opened this issue Jun 23, 2023 · 8 comments
Assignees
Labels
changelog-ignore Don't include this issue in the release changelog enhancement New feature or request

Comments

@tchaumeny
Copy link

What would you like to be added:

I couldn't find a way to disable the terminal coloring of output.
Usually, this is achievable by setting the env variable NO_COLOR=1, which has no effect with Syft.

Why is this needed:

This is useful when syft output is processed outside of the terminal.

@tchaumeny tchaumeny added the enhancement New feature or request label Jun 23, 2023
@spiffcs spiffcs added this to OSS Jun 28, 2023
@kzantow
Copy link
Contributor

kzantow commented Jun 29, 2023

Hi @tchaumeny we are currently looking to update a library to use Bubbletea, which will support that option. However, if you're looking to use the tools with logs, a better option might be using -q which means "quiet" as this disables the real-time terminal UI in favor of just outputting the SBOM directly to stdout.

@kzantow kzantow moved this to Backlog in OSS Jun 29, 2023
@wagoodman
Copy link
Contributor

While working on the bubbletea port PR I tried out the NO_COLOR env var on the current version of syft and it seemed to work

Screenshot 2023-06-30 at 9 01 31 AM

(I've also confirmed the same behavior when swapping to bubbletea). Can you let me know what distro name and version you're running on and how you're invoking syft?

@tchaumeny
Copy link
Author

I'm using syft on macos 13.3.1, here is an example:

Screenshot 2023-06-30 at 16 21 15

@wagoodman
Copy link
Contributor

wagoodman commented Jun 30, 2023

Curious! what shell and terminal emulator are you using? And what is the value of the TERM env var?

@tchaumeny
Copy link
Author

The shell is zsh on macos native Terminal, and TERM=xterm-256color

@tchaumeny
Copy link
Author

Oh actually I noticed I have the same behavior as you have on your screenshot, NO_COLOR=1 actually disables colors for the output below. It doesn't for the additional output generated with the -vflag.

Screenshot 2023-06-30 at 16 45 42

@wagoodman
Copy link
Contributor

ah! that's helpful, I think I know where the problem is. Our logger has been configured to always enforce color, we can adjust that.

@willmurphyscode
Copy link
Contributor

I believe this was fixed by intermediate development, since the fix in anchore/clio#14 was pulled into syft in #2001.

With color on:

image

With NO_COLOR=1 in the environment:

image

@tchaumeny Thanks for reporting this issue! Please let us know if we've missed something.

@github-project-automation github-project-automation bot moved this from In Progress to Done in OSS Sep 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog-ignore Don't include this issue in the release changelog enhancement New feature or request
Projects
Archived in project
Development

No branches or pull requests

4 participants