Skip to content
/ gendiff Public

PHP_p2. Difference calculator: a program that determines the difference between two data structures

Notifications You must be signed in to change notification settings

rnik82/gendiff

Repository files navigation

Hexlet tests and linter status:

Actions Status hexlet-check

Gendiff (Difference Calculator)

About the Project:

Difference Calculator is a program that determines the difference between two data structures. This is a popular problem, and there are many online services available to solve it, such as: http://www.jsondiff.com/. A similar mechanism is used when displaying test results or automatically tracking changes in configuration files.

Features of the Utility:

  • Support for different input formats: YAML and JSON
  • Report generation in plain text, stylish, and JSON formats

Requirements

  • Linux
  • PHP 8.3
  • Composer

Installation Instructions

Follow these steps sequentially:

  1. Clone the repository:

    git clone git@github.com:rnik82/gendiff.git difference-calculator
  2. Navigate to the project directory:

    cd difference-calculator
  3. Install dependencies:

    make install
  4. Grant execute permissions to the files in the bin directory:

    chmod +x ./bin/*

Running the Program

Commands to run the program:

  • ./bin/gendiff -h — display help.
  • ./bin/gendiff file1.json file2.json --format stylish — compare JSON files in stylish format
  • ./bin/gendiff file1.yml file2.yml --format stylish — compare YAML files in stylish format
  • ./bin/gendiff file1.json file2.json --format plain — compare JSON files in plain format
  • ./bin/gendiff file1.yml file2.yml --format plain — compare YAML files in plain format
  • ./bin/gendiff file1.json file2.json --format json — compare JSON files in JSON format
  • ./bin/gendiff file1.yml file2.yml --format json — compare YAML files in JSON format
  • ./bin/gendiff file1.json file2.json — if no format is specified, stylish will be used by default

Demonstration

Displaying help and example of comparing JSON files

asciicast

Example of comparing YAML (YML) files

asciicast

Example of comparing JSON and YAML files with nested structure in default stylish format

asciicast

Example of comparing JSON and YAML files with nested structure in plain format

asciicast

Example of comparing JSON and YAML files with nested structure in json format

asciicast

About

PHP_p2. Difference calculator: a program that determines the difference between two data structures

Resources

Stars

Watchers

Forks

Packages

No packages published