udiff: Unix diff compact-mode parser
| (require udiff) | package: udiff | 
1 Introduction
udiff is a compact-mode diff(1) parser written in Racket.
1.1 Features
- CLI tool with JSON output for easy scripting. 
- Summary mode to get quick diff stats. 
- Racket API to let you directly get diff output in your projects. 
2 Installation
Assuming you’ve already installed Racket, run the following command to install udiff.
$ raco pkg install udiff
3 Usage examples
By default, udiff expects to receive the diff output from stdin.
$ diff -d old-file new-file | udiff | jq
Currently, udiff is specifically built to diff TSV files. It’s in my plans to broaden the diff scope and allow for more versatile usage of this tool.
4 JSON structure
The JSON output returns a JSON document structured as follows.
- additions: an array of lines that only appear in the second file. 
- deletions: an array of lines that only appear in the first file. 
- changes: an array of objects containing both the previous (i.e. deleted) and next (i.e. added) versions of the changed row. 
The object format for changes is as follows.
{ "from": "line in the first file", "to": "line in the second file" }