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

Add support check functions. #56

Merged
merged 2 commits into from
Jan 31, 2016
Merged

Add support check functions. #56

merged 2 commits into from
Jan 31, 2016

Conversation

Stebalien
Copy link
Owner

This makes it easy to determine if the terminal supports color.

/cc @cmr, @alexcrichton

This is part of fixing rust-lang/cargo#2338 (comment).

The terminals in question do not support color. We used to return Ok(false) when a program tried to use an unsupported attribute but we now return an error (Err(Error::NotSupported)). This patch makes it possible to check supports_color up front to avoid running into this issue.

I'm asking for a review because I don't know if supports_color should imply supports_reset or if we should have the programmer call supports_reset() && supports_color(). Can you think of any cases where one might care about supporting terminals that support color but not resetting those colors to their defaults? Do any such terminals even exist?

Once I get this merged and I cut yet another release, cargo can call term.supports_color() after creating the terminal to make sure the terminal will actually be useful.

This makes it easy to determine if the terminal supports color.
@alexcrichton
Copy link
Collaborator

Seems reasonable to me!

Stebalien added a commit that referenced this pull request Jan 31, 2016
@Stebalien Stebalien merged commit 4d56f91 into master Jan 31, 2016
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