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

make color output detect terminals? #27

Open
josharian opened this issue Jun 28, 2021 · 1 comment
Open

make color output detect terminals? #27

josharian opened this issue Jun 28, 2021 · 1 comment

Comments

@josharian
Copy link
Contributor

Should we do terminal detection automatically? See e.g. tailscale/depaware#11.

It would add significant dependencies, which is unfortunate. Perhaps we should instead provide easily copy/paste-able code that does it? Or maybe with lazy module loading in 1.17 it is enough to put terminal detection in its own package?

@mvdan
Copy link
Contributor

mvdan commented Jun 29, 2021

I think deciding when to output color is going to vary between each downstream application. For example: What should the default be? Should they obey TERM=dumb and NO_COLOR? Should they have a flag to force color on? Should they also hook up a flag for any of this, like --color?

In terms of dependencies it wouldn't be huge, because you could use https://pkg.go.dev/golang.org/x/term#IsTerminal, but it's still an extra dep.

My vote goes for having a ready to use example people can copy from. We could perhaps make it a runnable example if we mock term.IsTerminal, and instead just link to pkg.go.dev in a comment.

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