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

Make iter and into_iter part of the public interface in StyledStr #4611

Closed
2 tasks done
makspll opened this issue Jan 8, 2023 · 4 comments
Closed
2 tasks done

Make iter and into_iter part of the public interface in StyledStr #4611

makspll opened this issue Jan 8, 2023 · 4 comments
Labels
C-enhancement Category: Raise on the bar on expectations

Comments

@makspll
Copy link

makspll commented Jan 8, 2023

Please complete the following tasks

Clap Version

4.0.32

Describe your use case

I am using clap to power an in-game console, I'd rather not parse ansii characters back to colour information to format the text.

Describe the solution you'd like

Make the iteration functionality of StyledStr part of the public interface

Alternatives, if applicable

No response

Additional Context

No response

@makspll makspll added the C-enhancement Category: Raise on the bar on expectations label Jan 8, 2023
@epage
Copy link
Member

epage commented Jan 9, 2023

The internals of StyledStr are not public because they are subject to change which will happen soon. Our plan is to write ANSI codes directly into a String and strip them when needed, so you doing that on your side aligns with where we are going.

The original reason we are doing this is to allow users to provide formatted text without having to also maintaining a bespoke formatting API for #1433, #3108. We also found that the current approach is very expensive in binary size terms which are we working to reduce (#1365).

@makspll
Copy link
Author

makspll commented Jan 9, 2023

Hmm so would formatting be done by writing ANSI into the StyledStr or String directly? Is it at least going to be possible to force ansii output, without using the cross-platform capabilities of termcolor ?

@epage
Copy link
Member

epage commented Jan 9, 2023

StyledStr will be a newtype around String with the same API as today (ability to get a Display with and without ansi codes).

Users can use their crate of choice (e.g. owo-colors) to write ansi codes to a StyledStr. We will either

  • (no tty) Strip those codes
  • (unix) Write the codes
  • (windows) Output the codes if supported, otherwise turn them into wincon calls

As most of the work of termcolor will not be needed, my plan is to write a minimal crate to support the above policy.

@makspll
Copy link
Author

makspll commented Jan 9, 2023

I see, thanks!

@makspll makspll closed this as completed Jan 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-enhancement Category: Raise on the bar on expectations
Projects
None yet
Development

No branches or pull requests

2 participants