-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #240 from epage/diff
fix(snap): Finish swapping colors
- Loading branch information
Showing
3 changed files
with
30 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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}"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters