This package contains a command-line (CLI) tool that compares two files and prints the changes made in the second file. The tool supports JSON or YAML/YML formats for input files and offers three output formats based on CLI parameters.
To build and install the package, follow these instructions:
-
Windows:
- Run
make setup
for building, installing, and reinstalling the package.
- Run
-
Linux (tested on Ubuntu 22.04.4 LTS):
- Execute
make setup-linux
for the same tasks.
- Execute
-
If Poetry faces issues with the virtual environment, remove the project environments using
make remove-envs
.
- Default Usage Example with Stylish Formatter:
gendiff file1.json file2.json
- Usage with Plain Formatter:
gendiff -f plain file1.yaml file2.yaml
- Usage with JSON Formatter:
gendiff -f json file1.json file2.yaml
- Help Command:
gendiff -h
- JSON Files:
- YAML Files:
- Mixed JSON and YAML:
- Nested JSONs:
- Plain Formatter:
- JSON Formatter:
The tool represents differences in dictionaries accumulated in a list. Here's an example:
[{
"key": "common",
"status": "nested",
"children": [{
"key": "follow",
"status": "added",
"values": false
}, {
"key": "setting1",
"status": "unchanged",
"values": "Value 1"
}, {
"key": "setting2",
"status": "removed",
"values": 200
}, {
"key": "setting3",
"status": "updated",
"old_value": true,
"new_value": {
"key": "value"
}
}]
}]
Here:
- the key is a name of an object originating from source files,
- values are contents of plain objects and children are contents of nested objects,
- unchanged type of updated nested objects indicated with nested status,.