/gendiff

JSON/YAML difference generator

Primary LanguagePython

Gendiff

hexlet-check lint and test Maintainability Test Coverage


Description

"Gendiff" is a program that determines the difference between two data structures.

Features of the utility:

  • Supports different input formats: yaml (yml), json
  • Report generation as plain text, stylish and json

Dependencies

Tool Version
python "^3.8.1"
PyYAML "^6.0"

Installation

Before installation, make sure that you have Poetry installed.

  1. Clone the repository to your computer git clone https://github.com/ratushnyyvm/gendiff.git
  2. Go to the project folder cd gendiff
  3. Install the program make setup

Usage

Cli-utility

$ gendiff -h
usage: gendiff [-h] [-f {stylish,plain,json}] first_file second_file

Compares two configuration files and shows a difference.

positional arguments:
  first_file
  second_file

optional arguments:
  -h, --help            show this help message and exit
  -f {stylish,plain,json}, --format {stylish,plain,json}
                        set format of output (default: "stylish")

Library

from gendiff import generate_diff

diff = generate_diff(file_path1, file_path2)
print(diff)

Demonstration

installation

asciicast

stylish

gendiff path/to/file1 path/to/file2
gendiff path/to/file1 path/to/file2 -f stylish
gendiff path/to/file1 path/to/file2 --format stylish

asciicast

plain

gendiff path/to/file1 path/to/file2 -f plain
gendiff path/to/file1 path/to/file2 --format plain

asciicast

json

gendiff path/to/file1 path/to/file2 -f json
gendiff path/to/file1 path/to/file2 --format json

asciicast