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

Problem on console without support of color. #177

Open
hellishvictor opened this issue May 5, 2024 · 2 comments
Open

Problem on console without support of color. #177

hellishvictor opened this issue May 5, 2024 · 2 comments

Comments

@hellishvictor
Copy link

Hi, I'm a user of Win 7 x64 and with cmd I have to use the "--color never" option, but it get bypassed when there's an error and shows:

←[31mError:←[0m undefined filter ←[38;5;246m╭←[0m←[38;5;246m─←[0m←[38;5;246m[←[0m<unknown>:1:14←[38;5;246m]←[0m ←[38;5;246m│←[0m ←[38;5;246m1 │←[0m ←[38;5;249m.←[0m←[38;5;249m[←[0m←[38;5;249m]←[0m←[38;5;249m ←[0m←[38;5;249m|←[0m ←[38;5;249m ←[0m←[38;5;249m.←[0m←[38;5;249mn←[0m←[38;5;249ma←[0m←[38;5;249mm←[0m←[38;5;249me←[0m←[38 ;5;249m,←[0m←[38;5;249m ←[0m←[31me←[0m←[31mv←[0m←[31me←[0m←[31mn←[0m←[31mt←[0m←[31ms←[0m←[38;5;249m[ ←[0m←[38;5;249m]←[0m ←[38;5;240m │←[0m ←[31m─←[0m←[31m─←[0m←[31m─←[0m←[31m┬←[0m←[31m─←[0m←[31m─←[0m ←[38;5;240m │←[0m ←[31m╰←[0m←[31m─←[0m←[31m─←[0m←[31m─←[0m←[31m─←[0m undefined fil ter ←[38;5;246m───╯←[0m

Cheers.

@kklingenberg
Copy link
Contributor

This happens here:

jaq/jaq/src/main.rs

Lines 489 to 500 in 1699a7d

fn report<'a>(e: chumsky::error::Simple<String>) -> ariadne::Report<'a> {
use ariadne::{Color, Fmt, Label, Report, ReportKind};
use chumsky::error::SimpleReason;
// color error messages only if we are on a tty
let isatty = atty::is(atty::Stream::Stderr);
let (red, yellow) = if isatty {
(Color::Red, Color::Yellow)
} else {
(Color::Unset, Color::Unset)
};
let config = ariadne::Config::default().with_color(isatty);

Sadly this is part of a trait implementation for std::process::Termination and I can't find a neat way of propagating the --color cli option to this call. Making the cli options global would do it (as in using OnceCell) but that's a big change. Another path would be to try the supports_color crate.

@hellishvictor
Copy link
Author

Another path would be to try the supports_color crate.

That would be fine, I do have the NO_COLOR variable included on my environment, because a lot of CLI out there use it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants