Skip to content

Kassy-8/cli-compare-tool

Repository files navigation

Hexlet tests and linter status:

Actions Status Test workflow Maintainability Test Coverage

Compare tool for data structures

This repository is created as part of education on Hexlet.

Command line utility for comparison two data files and getting differences between them. It supports next file formats:

  • Supports next file formats: JSON, YAML.
  • Can provide report in stylish, plain on json formats.

Setup:

Clone repository:

git clone [email protected]:Kassy-8/frontend-project-lvl2.git

Install dependencies

npm ci

Install games as global package:

npm link

Usage

Usage: gendiff [options] <filepath1> <filepath2>

Options:
  -v, --version        output the version number
  -f, --format <type>  output format (default: "stylish")
  -h, --help           output usage information

You can use relative or absolute paths.

Example for JSON-files, output format - stylish (by default):

gendiff file1.json file2.json

{
    common: {
      + follow: false
        setting1: Value 1
      - setting2: 200
      - setting3: true
      + setting3: null
      + setting4: blah blah
      + setting5: {
            key5: value5
        }
    .....
}

Example for stylish format

Example for YAML-files, output format - plain:

gendiff -f plain file1.yml file2.yml
Property 'common.follow' was added with value: false
Property 'common.setting2' was removed
Property 'common.setting3' was updated. From true to null
Property 'common.setting4' was added with value: 'blah blah'
Property 'common.setting5' was added with value: [complex value]
...

Example for plain format

Example for JSON-files, output format - JSON:

gendiff - f json file1.json file2.json

[{"key":"common","type":"unchanged","value":[{"key":"follow","type":"added","value":false},{"key":"setting1","type":"unchanged","value":"Value 1"},{"key":"setting2","type":"removed","value":200},{"key":"setting3","type":"update","valueBefore":true,"valueAfter":null},{"key":"setting4","type":"added","value":"blah blah"},{"key":"setting5","type":"added","value":{"key5":"value5"}} ...]

Example for json format

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published