diffdirs 0.2.6

Compare two directories and show differences in files or subdirectories with colorized output, depth limiting, and JSON support.
diffdirs-0.2.6 is not a library.

diffdirs

A fast, minimal Rust CLI tool for comparing the contents of two directories. Displays which files or directories exist only in one location or the other, with optional color output, depth limiting, and JSON support.

Features

  • Compare two directories for unique paths
  • Show only files (default) or only directories (--dirs)
  • Limit recursion depth with --depth
  • Output results as JSON (--json)
  • Colorized terminal output for readability

Installation

Build and install from source:

cargo install --path .

or clone and run locally:

git clone https://github.com/fibnas/diffdirs.git
cd diffdirs
cargo build --release

The binary will be available at target/release/diffdirs.

Usage

diffdirs [OPTIONS] <DIR_A> <DIR_B>

Arguments

Argument Description
<DIR_A> First directory to compare
<DIR_B> Second directory to compare

Options

Option Description
--dirs Compare only directories (not files)
--depth <DEPTH> Maximum depth to traverse (0 = only root)
--json Output results in JSON format
-h, --help Show help information

Examples

Compare two directories (default: files only):

diffdirs ~/test-a ~/test-b

Compare directories only:

diffdirs ~/test-a ~/test-b --dirs

Limit depth to 1:

diffdirs ~/test-a ~/test-b --depth 1

Output as JSON:

diffdirs ~/test-a ~/test-b --dirs --json

Example JSON output:

{
  "only_in_a": [
    "echo",
    "foxtrot"
  ],
  "only_in_b": [
    "bravo",
    "alpha",
    "charlie",
    "delta"
  ],
  "summary": {
    "unique_in_a": 2,
    "unique_in_b": 4
  }
}

Example Output (default mode)

Files that appear only in /home/fn/test-a: (6)
  file1
  file2
  echo/info.txt
  todo.txt
  notes.txt
  file3

Files that appear only in /home/fn/test-b: (4)
  cheatsheet.txt
  file5
  delta/secret.txt
  file4

Summary: 6 unique in /home/fn/test-a, 4 unique in /home/fn/test-b

Acknowledgements

Inspired by earlier directory diff tools such as diffdir, with a focus on modern CLI ergonomics and flexible output formats.

  • walkdir for fast recursive directory traversal
  • clap for ergonomic CLI argument parsing
  • yansi for lightweight colorized output
  • serde_json for clean JSON serialization
  • Inspiration from classic UNIX diff and tree utilities

License

MIT License See LICENSE for details.