Skip to content

Сommand-line utility that compares two data structures and identifies discrepancies such as added, removed, or changed keys and values.

Notifications You must be signed in to change notification settings

rostex/differ-cli

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Difference CLI

Differ CLI is a command-line utility for comparing text files providing a visual difference between them. It allows users to quickly see the differences between two versions of a file and can be used in various contexts, such as version control, backup comparison, and more.

Status:

Actions Status Java CI Maintainability Test Coverage

Supported File Formats

Differ CLI supports the following file formats for comparison:

  • JSON Files (.json) - JavaScript Object Notation (JSON) formatted files.
  • XML Files (.xml) - Extensible Markup Language files.
  • YAML Files (.yaml, .yml) - YAML (YAML Ain't Markup Language) formatted files.

Currently, the utility is designed to work with text-based formats. Binary files and non-text formats are not supported.

Links to Other Sections:

Installation

For macOS and Ubuntu (Linux)

To install Differ CLI, follow these steps:

  1. Download the Installer Script: Download the installation script by running the following command in your terminal:

    curl -L https://github.com/rostex/differ-cli/releases/download/v1.0.0/install-getdiff.sh -o install-getdiff.sh
  2. Make the Script Executable: Change the permissions of the script to make it executable:

    chmod +x install-getdiff.sh
  3. Run the Installation Script: Execute the script to install the utility:

    ./install-getdiff.sh

    The script will:

    • Download the latest version of the getdiff.jar file.
    • Create a directory called ~/.getdiff in your home directory.
    • Place the JAR file inside this directory.
    • Create a command script to launch the utility using Java.
    • Add the installation directory to your PATH environment variable, so you can run the utility globally.
  4. Verify Installation
    To verify that the utility has been installed correctly, open a regular Command Prompt or PowerShell window and run the following command:

    getdiff --version

For Windows

To install Differ CLI, follow these steps:

  1. Download the Installer Script:

    1. To download it using the command line, open PowerShell and run the following command:
    Invoke-WebRequest -Uri "https://github.com/rostex/differ-cli/releases/download/v1.0.0/install-getdiff.ps1" -OutFile "$env:USERPROFILE\Downloads\install-getdiff.ps1"
    1. Ensure that the file has been successfully downloaded and is located in your current directory (e.g., C:\Users\Your_Name\Downloads).
  2. Run the Installation Script

    1. Open PowerShell as an Administrator. This is required to modify the PATH environment variable and make the utility globally available. To do this:

      • Search for PowerShell in the Start menu.
      • Right-click and choose Run as Administrator.
    2. In PowerShell, navigate to the folder where the install-getdiff.ps1 script was saved. For example, if the file is in your Downloads folder, use the following command:

      cd C:\Users\Your_Name\Downloads
    3. Now, execute the script:

      .\install-getdiff.ps1

      The script will:

      • Download the getdiff.jar file to C:\Users\Your_Name.getdiff.
      • Create an executable command file getdiff.cmd to launch the utility.
      • Add the installation directory to your PATH environment variable, allowing you to run the utility from anywhere in the command line.
    4. After the script finishes, a message will be displayed indicating that the installation is complete.

  3. Verify Installation
    To verify that the utility has been installed correctly, open a regular Command Prompt or PowerShell window and run the following command:

    getdiff --version

Usage

After installation, you can use Differ CLI directly from the terminal with the following command:

getdiff <file1> <file2>

Example

To compare two Yaml files:

getdiff --format=plain file1.yaml file2.yaml

This will output the differences between the two files in the terminal.

For more information:

# Plain format
getdiff --format=plain path/to/file.yml another/path/file.json

Property 'follow' was added with value: false
Property 'baz' was updated. From 'bas' to 'bars'
Property 'group2' was removed

# Stylish format
getdiff file1.json file2.json

{
  + follow: false
  + numbers: [1, 2, 3]
    setting1: Value 1
  - setting2: 200
  - setting3: true
  + setting3: {key=value}
  + setting4: blah blah
}

Uninstallation

For macOS and Ubuntu (Linux)

If you wish to uninstall Differ CLI, follow these steps:

  1. Download the Uninstallation Script: Download the uninstall script by running the following command in your terminal:

    curl -L https://github.com/rostex/differ-cli/releases/download/v1.0.0/uninstall-getdiff.sh -o uninstall-getdiff.sh
  2. Make the Script Executable: Change the permissions of the script to make it executable

    chmod +x uninstall-getdiff.sh
  3. Run the Uninstallation Script: Execute the script to uninstall the utility:

    ./uninstall-getdiff.sh

The script will:

  • Remove the getdiff.jar file and command script.
  • Delete the ~/.getdiff directory.
  • Remove the installation directory from your PATH variable.

For Windows

If you wish to uninstall Differ CLI, follow these steps:

  1. Download the Uninstallation Script: Download the uninstallation script by running the following command in PowerShell:

    Invoke-WebRequest -Uri "https://github.com/rostex/differ-cli/releases/download/v1.0.0/uninstall-getdiff.ps1" -OutFile     "$env:USERPROFILE\Downloads\uninstall-getdiff.ps1"
  2. Run the script as Administrator, just like the installation:

    .\uninstall-getdiff.ps1

The script will:

  • Remove the getdiff.jar file and command script.
  • Delete the ~/.getdiff directory.
  • Remove the installation directory from your PATH variable.

About

Сommand-line utility that compares two data structures and identifies discrepancies such as added, removed, or changed keys and values.

Topics

Resources

Stars

Watchers

Forks