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

fix(snap): Finish swapping colors #240

Merged
merged 2 commits into from
Dec 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions crates/snapbox/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -97,3 +97,7 @@ windows-sys = { version = "0.52.0", features = ["Win32_Foundation"], optional =

[target.'cfg(unix)'.dependencies]
libc = { version = "0.2.137", optional = true }

[[example]]
name = "diff"
required-features = ["diff"]
24 changes: 24 additions & 0 deletions crates/snapbox/examples/diff.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
fn main() {
let mut args = std::env::args();
let _ = args.next().expect("expects `$ diff <old> <new>`");
let old_path = args.next().expect("expects `$ diff <old> <new>`");
let new_path = args.next().expect("expects `$ diff <old> <new>`");
if args.next().is_some() {
panic!("expects `$ diff <old> <new>`");
}

let old = snapbox::Data::text(std::fs::read_to_string(&old_path).unwrap());
let new = snapbox::Data::text(std::fs::read_to_string(&new_path).unwrap());

let mut output = String::new();
snapbox::report::write_diff(
&mut output,
&old,
&new,
Some(&old_path),
Some(&new_path),
snapbox::report::Palette::color(),
)
.unwrap();
println!("{output}");
}
4 changes: 2 additions & 2 deletions crates/snapbox/src/report/color.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ impl Palette {
warn: anstyle::AnsiColor::Yellow.on_default(),
error: anstyle::AnsiColor::Red.on_default(),
hint: anstyle::Effects::DIMMED.into(),
expected: anstyle::AnsiColor::Green.on_default() | anstyle::Effects::UNDERLINE,
actual: anstyle::AnsiColor::Red.on_default() | anstyle::Effects::UNDERLINE,
expected: anstyle::AnsiColor::Red.on_default() | anstyle::Effects::UNDERLINE,
actual: anstyle::AnsiColor::Green.on_default() | anstyle::Effects::UNDERLINE,
}
} else {
Self::plain()
Expand Down
Loading