Giter Site home page Giter Site logo

gendiff's Introduction

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

gendiff's People

Contributors

fiftinmen avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.