Skip to content

fiftinmen/GenDiff

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

79 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Hexlet Tests and Linter Status

Actions Status Python CI Maintainability

Package Description

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.

Installation

To build and install the package, follow these instructions:

  • Windows:

    • Run make setup for building, installing, and reinstalling the package.
  • Linux (tested on Ubuntu 22.04.4 LTS):

    • Execute make setup-linux for the same tasks.
  • If Poetry faces issues with the virtual environment, remove the project environments using make remove-envs.

Usage

  1. Default Usage Example with Stylish Formatter:

gendiff file1.json file2.json

  1. Usage with Plain Formatter:

gendiff -f plain file1.yaml file2.yaml

  1. Usage with JSON Formatter:

gendiff -f json file1.json file2.yaml

  1. Help Command:

gendiff -h

Usage Demos

  • JSON Files:

asciicast

  • YAML Files:

asciicast

  • Mixed JSON and YAML:

asciicast

  • Nested JSONs:

asciicast

  • Plain Formatter:

asciicast

  • JSON Formatter:

asciicast

Inner Data Format

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,.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published