| Crates.io | xdiff-live |
| lib.rs | xdiff-live |
| version | 0.1.1 |
| created_at | 2025-07-20 12:33:28.736032+00 |
| updated_at | 2025-07-20 12:43:26.209636+00 |
| description | A live diff tool for comparing files and directories. |
| homepage | https://crates.io/crates/xdiff-live |
| repository | https://github.com/YanQD/xdiff_ng |
| max_upload_size | |
| id | 1761035 |
| size | 157,098 |
XDiff-NG is a powerful command-line toolkit for HTTP request comparison and construction, written in Rust. It provides two main utilities:
git clone https://github.com/YanQD/xdiff_ng.git
cd xdiff_ng
cargo build --release
The binaries will be available in target/release/:
xdiff-livexreq-livecargo install --path .
Basic comparison:
# Compare two API endpoints using a predefined profile
cargo run --bin xdiff-live -- run -p rust -c fixtures/test.yml
# Compare with extra parameters
cargo run --bin xdiff-live -- run -p rust -c fixtures/test.yml -e a=100 -e @b=2 -e m=10
Interactive mode:
# Parse and compare URLs interactively
cargo run --bin xdiff-live -- parse
# Then input URLs like:
# https://jsonplaceholder.typicode.com/todos/1?a=1&b=2
# https://jsonplaceholder.typicode.com/todos/2?a=2&b=3
# todo
Make HTTP requests:
# Execute a request using a predefined profile
cargo run --bin xreq-live -- run -p todo -c fixtures/xreq_test.yml
# Run with custom parameters
cargo run --bin xreq-live -- run -p api -c config.yml -e token=abc123
XDiff allows you to compare HTTP requests and responses between different environments or API versions. It's particularly useful for:
XDiff uses YAML configuration files to define comparison profiles. Each profile contains:
Example configuration:
---
# Profile for comparing Rust website responses
rust:
req1:
method: GET
url: https://www.rust-lang.org/
headers:
user-agent: Aloha
params:
hello: world
req2:
method: GET
url: https://www.rust-lang.org/
params: {}
res:
skip_headers:
- set-cookie
- date
- via
- x-amz-cf-id
skip_body:
- timestamp
- request_id
# Profile for comparing JSON API responses
todo:
req1:
url: https://jsonplaceholder.typicode.com/todos/1
params:
a: 100
req2:
url: https://jsonplaceholder.typicode.com/todos/2
params:
c: 200
res:
skip_headers:
- report-to
- date
- x-ratelimit-remaining
- x-ratelimit-reset
- cf-ray
- age
skip_body:
- id
xdiff-live <COMMAND>
Commands:
run Run diff comparison with specified profile
parse Interactive mode for parsing and comparing URLs
help Print this message or the help of the given subcommand(s)
Options for 'run':
-p, --profile <PROFILE> Profile name to use
-c, --config <CONFIG> Configuration file path
-e, --extra <EXTRA> Extra parameters (format: key=value or @key=value)
You can override or add parameters using the -e flag:
-e key=value: Add/override query parameter-e @key=value: Add/override header-e #key=value: Add/override body parameterXReq is a powerful HTTP client that builds requests based on predefined profiles. It's designed to replace curl or httpie for complex HTTP requests.
---
# API testing profile
api:
method: POST
url: https://api.example.com/users
headers:
content-type: application/json
authorization: Bearer {{token}}
body:
name: "{{name}}"
email: "{{email}}"
# Simple GET request profile
todo:
method: GET
url: https://jsonplaceholder.typicode.com/todos/{{id}}
params:
_limit: 10
xreq-live run -p <PROFILE> -c <CONFIG> [OPTIONS]
Options:
-p, --profile <PROFILE> Profile name to use
-c, --config <CONFIG> Configuration file path
-e, --extra <EXTRA> Extra parameters for substitution
Both tools use YAML configuration files. See yaml.md for detailed YAML syntax reference.
---
profile_name:
method: GET|POST|PUT|DELETE|PATCH # HTTP method (default: GET)
url: string # Request URL (required)
headers: # Request headers
key: value
params: # Query parameters
key: value
body: # Request body (for POST/PUT/PATCH)
key: value
res: # Response filtering (xdiff only)
skip_headers: # Headers to ignore in comparison
- header-name
skip_body: # Body fields to ignore in comparison
- field-name
Compare two different API endpoints:
# Compare todo items from JSONPlaceholder API
cargo run --bin xdiff-live -- run -p todo -c fixtures/test.yml
Compare the same endpoint across different environments:
---
api_comparison:
req1:
url: https://staging-api.example.com/users
headers:
authorization: Bearer staging-token
req2:
url: https://prod-api.example.com/users
headers:
authorization: Bearer prod-token
res:
skip_headers:
- date
- server
- x-request-id
Compare different API versions:
# Compare v1 vs v2 API responses
cargo run --bin xdiff-live -- run -p version_compare -c api_versions.yml
# Make a simple GET request
cargo run --bin xreq-live -- run -p todo -c fixtures/xreq_test.yml
# POST request with parameters
cargo run --bin xreq-live -- run -p create_user -c api.yml -e name="John Doe" -e email="john@example.com"
# Debug build
cargo build
# Release build
cargo build --release
# Run tests
cargo test
# Run with examples
cargo run --example highlight
cargo run --example similar
├── src/
│ ├── bin/ # Binary entry points
│ │ ├── xdiff.rs # xdiff CLI
│ │ └── xreq.rs # xreq CLI
│ ├── config/ # Configuration handling
│ ├── cli.rs # Command line interface
│ ├── lib.rs # Library exports
│ └── utils.rs # Utility functions
├── examples/ # Example code
├── fixtures/ # Test configuration files
├── tests/ # Integration tests
└── README.md # This file
# Run all tests
cargo test
# Run specific test
cargo test cli_tests
# Run with verbose output
cargo test -- --nocapture
git checkout -b feature/amazing-feature)git commit -m 'Add some amazing feature')git push origin feature/amazing-feature)This project is licensed under the MIT License - see the LICENSE file for details.
Initial release
Basic xdiff functionality for HTTP request comparison
xreq tool for making HTTP requests from profiles
YAML configuration support
Syntax highlighting for output
Interactive parsing mode