Skip to content

Do all ANSI codes get stripped out of help menu when printing to non-terminal/non-tty? #5211

Answered by epage
fritzrehde asked this question in Q&A
Discussion options

You must be logged in to vote

Yes, it is intentional that any API call that accepts StyledStr may have ANSI escape codes put in them and they will automatically be stripped when printing to "unsupported" terminals. For legacy Windows consoles, they will instead be covnerted to wincon API calls.

We wanted to allow users to style their text but had several limitations

  • We didn't want to provide a bespoke styling API (it'd end up looking like termcolor which is frustrating to use and doesn't integrate well with other work)
  • We didn't want users worrying about whether the string they were giving clap would go to stdout or stderr

This led to the creation of anstream. This means its available for you to use in your applicat…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@fritzrehde
Comment options

Answer selected by fritzrehde
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants