Skip to content

How to use colored output on Windows #5590

Closed Answered by fu050409
fu050409 asked this question in Q&A
Discussion options

You must be logged in to vote

I think I solved it and it looks like it was my problem.
It looks like even if clap is configured with ColorChoice::Always it doesn't show the colours by default, I was missing this part of the code:

{
    use clap::builder::styling;
    let styles = styling::Styles::styled()
      .header(styling::AnsiColor::Green.on_default() | styling::Effects::BOLD)
      .usage(styling::AnsiColor::Green.on_default() | styling::Effects::BOLD)
      .literal(styling::AnsiColor::Cyan.on_default() | styling::Effects::BOLD)
      .placeholder(styling::AnsiColor::Cyan.on_default());
    clap = clap.styles(styles);
}

Thank you for your patience in answering!

Replies: 1 comment 13 replies

Comment options

You must be logged in to vote
13 replies
@fu050409
Comment options

@epage
Comment options

@fu050409
Comment options

@fu050409
Comment options

Answer selected by fu050409
@epage
Comment options

@liciana24
Comment options

@fu050409
Comment options

@epage
Comment options

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