Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 checksupports_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.