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

Allow passing io.Writer instead of *os.File to the NewColorable func #65

Open
cardil opened this issue Feb 28, 2023 · 1 comment · May be fixed by #66
Open

Allow passing io.Writer instead of *os.File to the NewColorable func #65

cardil opened this issue Feb 28, 2023 · 1 comment · May be fixed by #66

Comments

@cardil
Copy link

cardil commented Feb 28, 2023

The NewColorable func forces users to pass a *os.File. It should accept io.Writer instead. The func could verify if a given writer is a real TTY, and act accordingly.

@dolmen
Copy link
Contributor

dolmen commented Mar 22, 2023

Why do you need this?

Why is the following function not enough?

func setColorable(w io.Writer) io.Writer {
    if f, isFile := w.(*os.File); isFile {
        return colorable.NewColorable(f)
    }
    return w
}

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 a pull request may close this issue.

2 participants