Skip to content

feat(cli): fine-grained color control - #586

Merged
woodruffw merged 15 commits into
mainfrom
ww/color-control
Mar 9, 2025
Merged

feat(cli): fine-grained color control#586
woodruffw merged 15 commits into
mainfrom
ww/color-control

Conversation

@woodruffw

@woodruffw woodruffw commented Mar 6, 2025

Copy link
Copy Markdown
Member

WIP.

This doesn't quite work yet, since tracing_indicatif and anstream::AutoStream don't compose cleanly. I'm not 100% sure if this is a fundamental incompatibility or API misuse on my part, yet.

This doesn't quite work yet, since tracing_indicatif
and anstream::AutoStream don't compose cleanly.
@woodruffw woodruffw added the cli label Mar 6, 2025
Signed-off-by: William Woodruff <william@yossarian.net>
@woodruffw

Copy link
Copy Markdown
Member Author

I thought about this some more, and I think this approach will never compose 100% to my liking: anstream is designed to strip all ANSI escapes, including the escapes that make progress bars render nicely. In other words, there's no clean composition between tracing_indicatif and anstream at the tracing writer level, since the former always wants some degree of ANSI escaping and the latter always wants to filter ANSI codes (when requested).

Instead, the better approach here is probably to avoid composing the "no color" and progress bar use cases: forcefully disabling colors should probably also disable the progress bar, even though it's technically its own thing.

The alternative to the above would be do so something more like what uv does, i.e. maintain a Printer abstraction that cooperates with a separate progress bar manager to ensure everything remains synchronized without having to cross underlying I/O streams.

@woodruffw

Copy link
Copy Markdown
Member Author

The above is no longer an immediate problem, since --no-progress (#589) means that we can disable the progress bar in the troublesome case.

As such, this is now close enough to what I'm thinking. But it still needs tests.

@woodruffw woodruffw self-assigned this Mar 9, 2025
@woodruffw
woodruffw merged commit 43a1d5e into main Mar 9, 2025
@woodruffw
woodruffw deleted the ww/color-control branch March 9, 2025 20:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant