Crates.io | line_diff |
lib.rs | line_diff |
version | 0.13.2 |
source | src |
created_at | 2019-11-28 20:26:02.480545 |
updated_at | 2023-07-06 17:24:50.38204 |
description | A tool to compare single lines by tokenizing them into chunks |
homepage | https://github.com/niederb/line_diff |
repository | https://github.com/niederb/line_diff |
max_upload_size | |
id | 185143 |
size | 52,743 |
Tool to compare two single lines of text. The intended use case is to compare long lines where parts are different or missing. Example use cases:
Comparing to different cargo commands with arguments in different order. With line_diff it is easy to spot that the only difference is the --release argument
Line 1:
cargo run -- -o --file f1.txt -s ",;"
Line 2:
cargo run --release -- --file f1.txt -s ",;" -o
┌────────┬────────────┬───────────┐
│ Line 1 │ Same │ Line 2 │
├────────┼────────────┼───────────┤
│ │ ",;" │ │
│ │ -- │ │
│ │ --file │ │
├────────┼────────────┼───────────┤
│ │ │ --release │
├────────┼────────────┼───────────┤
│ │ -o │ │
│ │ -s │ │
│ │ cargo │ │
│ │ f1.txt │ │
│ │ run │ │
├────────┼────────────┼───────────┤
│ 37 │ Characters │ 47 │
├────────┼────────────┼───────────┤
│ 8 │ Chunks │ 9 │
└────────┴────────────┴───────────┘
Compare two lines from two different input files.
line_diff f1.txt f2.txt
Compare two lines from two different input files. With the -o option the chunks will be sorted before comparison. This is handy for cases such as compiler flags where the ordering does not matter.
line_diff f1.txt f2.txt -o
Compare two lines from two a single input file and with sorting of the chunks. Specify two different separators (' ' and ';') with the -s option
line_diff --file f1.txt -o -s ' ' ';'
Compare two lines by specifying the string on the command line
line_diff --line1 "hello world" --line2 "hello there"
Compare two lines, but first convert them both to lowercase
line_diff --line1 "hello world" --line2 "Hello wOrld" -l