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

feat: add feature according to issue 2781 #1

Closed
lindanycander opened this issue Feb 26, 2025 · 0 comments · Fixed by #2
Closed

feat: add feature according to issue 2781 #1

lindanycander opened this issue Feb 26, 2025 · 0 comments · Fixed by #2
Labels
enhancement New feature or request

Comments

@lindanycander
Copy link

lindanycander commented Feb 26, 2025

This is the description of the issue:
[Feature Request] Allow to to emit colored click.secho() text to a pipeline. 2781

Currently click.secho() strips the color information when the output stream is a pipe and not a terminal. With this feature, it will be possible to force click.secho() to preserve the colors even if writing to a pipe. This can be done at several levels and each one of them should work. For example having the functions below, at a global or per stream level. This will allow the parent process to pass the color policy to the subprocess via command line args.

enum ColorPolicy = ALLWAYS_KEEP | ALLWAYS_STRIP | AUTO

# Used at child process.
click.set_color_policy(color_policy:  ColorPolicy)

# Used at parent process.
click.get_color_policy() -> ColorPolicy                    

We have a python program that runs a scons script as a subprocess, captures it's stdout pipe, and sends it to a terminal. When we use ``click.secho() in the subprocess, the colors are removed. This result with the non desire outcome that some our output is colored and similar output that came from the subprocess is not.

I am not aware of a workaround.

@lindanycander lindanycander added the enhancement New feature or request label Feb 26, 2025
vilhelmprytz added a commit that referenced this issue Feb 27, 2025
fixes #1

Co-authored-by: Philip Ågren Jahnsson <[email protected]>
Co-authored-by: [email protected] <[email protected]>
@lindanycander lindanycander changed the title feat: add feature according to issue #2781 feat: add feature according to issue 2781 Mar 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant