-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Color output from CI jobs #1090
Comments
I don't want to hard code things like this, it ends up being an arbitrary list that we have to maintain. An environment variable, such as |
@davidism good point. I agree with you, making click have knowledge of various environments which may run a click program is probably the wrong way to go. Is there a generic solution adopted by other programs, like Perhaps implemented as a default click option (like |
GitLab, Travis, etc. don't need to know about Click. You would add an env var for the test job. |
I would think that it would be the responsibility of GitLab, Travis, etc to know that they are able to properly handle color escape sequences. Unfortunately there doesn't seem to be a common environment variable to express this. For example, a non-empty DISPLAY variable tells programs that graphics are available. There is no generic variable to tell programs that ANSI colors should be used. |
Transcluding my comments from #558: the chalk JS package has those 13 000 depending packages. this (transitively) includes nearly all node.js command line applications. there’s no real standard for this. just check this mess i think we have convenient and expected would IMHO be to have a method that automatically adds a GNU-like |
for semantics:
|
I feel like this is already easy enough to implement if a project wants it. if __name__ == "__main__":
color = os.environ.get("CLICK_COLOR")
if color is not None: color = color in {"1", "true"}
cli(color=color) |
|
The point is it's now up to you exactly how you want to implement it. There's already a way to control color when main executes, as shown. |
I'm running My Jenkins is perfectly capable of displaying colors, but My options are: a) forking |
GitLab supports color escape sequences when viewing a job's output. Perhaps the same is true of GitHub, Jenkins, or other CI tools.
I'm guessing that the server running these commands is piping stdout and stderr to other processes or files which later get shipped over the wire. Because of this it is likely failing some
isatty()
call in_compat.py
.While it isn't a tty, it will eventually be displayed by something capable of handling colors. My current workaround is to detect if it's being ran as a GitLab CI job by the presence of an environment variable and explicitly setting
ctx.color = True
I think this is something that could/should be handled internally by click so that I don't have to add this workaround to every utility I write which may end up being used within some CI. Does anyone else agree?
workaround
The text was updated successfully, but these errors were encountered: