qmdx
Pipe and diff files: execute shell pipelines against multiple inputs, diff/compare/join results.
Install
pip install qmdx
CLIs
diff-x
Usage
diff-x
# Usage: diff-x [OPTIONS] [exec_cmd...] <path1> <path2>
#
# Diff two files after running them through a pipeline of other commands.
#
# Options:
# -c, --color Colorize the output
# -s, --shell-executable TEXT Shell to use for executing commands; defaults
# to $SHELL
# -S, --no-shell Don't pass `shell=True` to Python
# `subprocess`es
# -U, --unified INTEGER Number of lines of context to show (passes
# through to `diff`)
# -v, --verbose Log intermediate commands to stderr
# -w, --ignore-whitespace Ignore whitespace differences (pass `-w` to
# `diff`)
# -x, --exec-cmd TEXT Command(s) to execute before invoking `comm`;
# alternate syntax to passing commands as
# positional arguments
# --help Show this message and exit.
Examples
Given two similar JSON objects, where one is compact and the other is pretty-printed:
echo '{"a":1,"b":2}' > 1.json
echo '{"a":1,"b":3}' | jq > 2.json
diff {1,2}.json outputs the entirety of both objects:
1c1,4
< {"a":1,"b":2}
---
> {
> "a": 1,
> "b": 3
> }
diff-x 'jq .' {1,2}.json pretty-prints each side before diffing:
3c3
< "b": 2
---
> "b": 3
comm-x
comm essentially performs set intersection/difference; comm-x allows you to run a pipeline of commands on each input, before comparing them.
Usage
comm-x
# Usage: comm-x [OPTIONS] [exec_cmd...] <path1> <path2>
#
# Select or reject lines common to two input streams, after running each
# through a pipeline of other commands.
#
# Options:
# -1, --exclude-1 Exclude lines only found in the first pipeline
# -2, --exclude-2 Exclude lines only found in the second pipeline
# -3, --exclude-3 Exclude lines found in both pipelines
# -i, --case-insensitive Case insensitive comparison
# -s, --shell-executable TEXT Shell to use for executing commands; defaults
# to $SHELL
# -S, --no-shell Don't pass `shell=True` to Python
# `subprocess`es
# -v, --verbose Log intermediate commands to stderr
# -x, --exec-cmd TEXT Command(s) to execute before invoking `comm`;
# alternate syntax to passing commands as
# positional arguments
# --help Show this message and exit.
Examples
Given two similar lists of numbers, but in different orders:
seq 10 > 1.txt
seq 10 -2 0 > 2.txt
comm outputs gibberish, because the files aren't in sorted order:
comm 1.txt 2.txt
# 1
# 10
# 2
# 3
# 4
# 5
# 6
# 7
# 8
# comm: file 2 is not in sorted order
# 6
# 4
# 2
# 0
# 9
# comm: file 1 is not in sorted order
# 10
# comm: input is not in sorted order
comm-x sort sorts each file first:
comm-x sort 1.txt 2.txt
# 0
# 1
# 10
# 2
# 3
# 4
# 5
# 6
# 7
# 8
# 9
git-diff-x
Usage
git-diff-x --help
# Usage: git-diff-x [OPTIONS] [exec_cmd...] [<path> | - [paths...]]
#
# Diff files at two commits, or one commit and the current worktree, after
# applying an optional command pipeline.
#
# Examples:
#
# # Compare the number of lines (`wc -l`) in file `foo` at the previous vs.
# current commit (`-r HEAD^..HEAD`):
#
# git diff-x -r HEAD^..HEAD wc -l foo
#
# # Colorized (`-c`) diff of `md5sum`s of `foo`, at HEAD (last committed
# value) vs. the current worktree content:
#
# git diff-x -c md5sum foo
#
# # Use `-` to separate pipeline commands from paths (when more than one path
# is to be diffed), e.g. this compares the largest 10 numbers in `file{1,2}`
# (HEAD vs. worktree):
#
# git diff-x 'sort -rn' head - file1 file2
#
# Options:
# -c, --color Colorize the output
# -r, --refspec TEXT <commit 1>..<commit 2> (compare two commits) or
# <commit> (compare <commit> to the worktree)
# -R, --ref TEXT Diff a specific commit; alias for `-r
# <ref>^..<ref>`
# -s, --shell-executable TEXT Shell to use for executing commands; defaults
# to $SHELL
# -S, --no-shell Don't pass `shell=True` to Python
# `subprocess`es
# -U, --unified INTEGER Number of lines of context to show (passes
# through to `diff`)
# -v, --verbose Log intermediate commands to stderr
# -w, --ignore-whitespace Ignore whitespace differences (pass `-w` to
# `diff`)
# -x, --exec-cmd TEXT Command(s) to execute before invoking `comm`;
# alternate syntax to passing commands as
# positional arguments
# --help Show this message and exit.
Examples
Compare line-count (wc -l) of this README, before and after commit 8b7a761:
git-diff-x -R 8b7a761 'wc -l' README.md
# 1c1
# < 16
# ---
# > 206
Examples from --help above:
# Compare the number of lines (`wc -l`) in file `foo` at the previous vs. current commit
# (`-R HEAD` is equivalent to `-r HEAD^..HEAD`).
git diff-x -R HEAD wc -l foo
# Colorized (`-c`) diff of `md5sum`s of `foo`, at HEAD (last committed value) vs. the current
# worktree content.
git diff-x -c md5sum foo
# Use `-` to separate pipeline commands from paths (when more than one path is to be diffed),
# e.g. this compares the largest 10 numbers in `file{1,2}` (HEAD vs. worktree):
git diff-x 'sort -rn' head - file1 file2
I use git-diff-x via several Git and Bash aliases:
[alias]
; pip install qmdx
dx = diff-x
dxc = diff-x -c
dxcr = diff-x -cR
dxcrr = diff-x -cr
dxr = diff-x -R
dxrr = diff-x -r
dxw = diff-x -w
dxwr = diff-x -wR
dxwrr = diff-x -wr
alias gdx="g dx"
alias gdxc="g dxc"
alias gdxcr="g dxcr"
alias gdxcrr="g dxcrr"
alias gdxr="g dxr"
alias gdxrr="g dxrr"
alias gdxw="g dxw"
alias gdxwr="g dxwr"
alias gdxwrr="g dxwrr"
Metadata
Release files for qmdx 0.0.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| qmdx-0.0.5.tar.gz | 8.8 kB | Without provenance | Details for qmdx-0.0.5.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| qmdx-0.0.5-py3-none-any.whl | Python 3 | none | any | Details for qmdx-0.0.5-py3-none-any.whl |
Total release size: 18.3 kB
Release files / qmdx-0.0.5.tar.gz
| Download URL | qmdx-0.0.5.tar.gz |
|---|---|
| Size | 8.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a394c0c3fa2b2e6edd5d0a5fec8a3e64cf66c6859010a09598f2b515242561c8
|
|
BLAKE2b-256 checksum How to use checksums |
d9b4087848ddc362eaa32f3a502b7e02384c0cb305b8f0823c418fc40a2ddabe
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.0.1 CPython/3.11.11
|
Release files / qmdx-0.0.5-py3-none-any.whl
| Download URL | qmdx-0.0.5-py3-none-any.whl |
|---|---|
| Size | 9.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
786489ccc0554b232a16e65de4f311a0d89d99b64f6873e4243ba6cc788da045
|
|
BLAKE2b-256 checksum How to use checksums |
7d9293ce826405b2add4f2bd30cdb318ad38dbb3ab7876639409e847c89e8e66
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.0.1 CPython/3.11.11
|
Security for qmdx 0.0.5
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.