likewise/examples/udiff.rs
Armin Ronacher 020701c4d5 Improve diff op grouping for full matches
This changes the behavior of the diff op grouping function to return
an empty result if the diff is a full match.  This also adds an example
to demonstrate unified diff rendering.
2021-01-30 23:11:35 +01:00

22 lines
556 B
Rust

use std::fs::read_to_string;
use std::process::exit;
use similar::text::TextDiff;
fn main() {
let args: Vec<_> = std::env::args_os().collect();
if args.len() != 3 {
eprintln!("usage: udiff [old] [new]");
exit(1);
}
let old = read_to_string(&args[1]).unwrap();
let new = read_to_string(&args[2]).unwrap();
print!(
"{}",
TextDiff::from_lines(&old, &new).unified_diff().header(
&args[1].as_os_str().to_string_lossy(),
&args[2].as_os_str().to_string_lossy()
)
);
}