Git Product home page Git Product logo

line_diff's Introduction

line_diff

Rust Tool to compare two single lines of text. The intended use case is to compare long lines where parts are different or missing. Example use cases:

  • long command lines with many arguments and flags
  • Compiler commands with many paths (with potentially different order)
  • Long function declarations with slightly different arguments

Features

  • Multiple, user specified separators
  • Converting all text to lowercase
  • Sorting chunks before comparing the chunks
  • Different input options: Command line, two files, single file or standard input
  • Statistics about the number of chunks and number of characters
  • Store preprocessed data into files in order to use external diff tool

Example output

Comparing to different cargo commands with arguments in different order. With line_diff it is easy to spot that the only difference is the --release argument

Line 1: 
cargo run -- -o --file f1.txt -s ",;"
Line 2:
cargo run --release -- --file f1.txt -s ",;" -o
┌────────┬────────────┬───────────┐
│ Line 1 │    Same    │  Line 2   │
├────────┼────────────┼───────────┤
│        │ ",;"       │           │
│        │ --         │           │
│        │ --file     │           │
├────────┼────────────┼───────────┤
│        │            │ --release │
├────────┼────────────┼───────────┤
│        │ -o         │           │
│        │ -s         │           │
│        │ cargo      │           │
│        │ f1.txt     │           │
│        │ run        │           │
├────────┼────────────┼───────────┤
│   37   │ Characters │    47     │
├────────┼────────────┼───────────┤
│   8    │   Chunks   │     9     │
└────────┴────────────┴───────────┘

Examples

Compare two lines from two different input files.

line_diff f1.txt f2.txt

Compare two lines from two different input files. With the -o option the chunks will be sorted before comparison. This is handy for cases such as compiler flags where the ordering does not matter.

line_diff f1.txt f2.txt -o

Compare two lines from two a single input file and with sorting of the chunks. Specify two different separators (' ' and ';') with the -s option

line_diff --file f1.txt -o -s ' ' ';'

Compare two lines by specifying the string on the command line

line_diff --line1 "hello world" --line2 "hello there"

Compare two lines, but first convert them both to lowercase

line_diff --line1 "hello world" --line2 "Hello wOrld" -l

line_diff's People

Contributors

niederb avatar

Stargazers

 avatar  avatar  avatar

Watchers

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