1 unstable release
Uses new Rust 2024
| 0.2.0 | Apr 6, 2026 |
|---|
#2904 in Command line utilities
730KB
18K
SLoC
diffguard
Command-line interface for diff-scoped governance linting.
This crate is the workspace I/O boundary. It owns:
- CLI parsing (
clap) - config loading/merge (
diffguard.toml, includes, env expansion) - git integration (
base/head,--staged, blame filtering) - invoking
diffguard-core - writing receipts/reports and returning stable exit codes
Install
# crates.io
cargo install diffguard
# workspace source
cargo install --path crates/diffguard
Command Surface
diffguard commands:
check- evaluate rules on diff-scoped linesrules- print effective rules (toml/json)explain- show details for one rule IDvalidate- validate config regex/globs and optional strict checksinit- write starterdiffguard.tomltest- runrule.test_casesfrom configtrend- summarize trend-history filessarif/junit/csv- render existing receipt files
Quick Start
diffguard init --preset minimal
diffguard check \
--base origin/main \
--head HEAD \
--config diffguard.toml \
--out artifacts/diffguard/report.json \
--md artifacts/diffguard/comment.md \
--sarif artifacts/diffguard/report.sarif.json \
--github-annotations
Non-git input is also supported:
diffguard check --diff-file patch.diff
git diff --cached | diffguard check --diff-file -
check Highlights
Input selection:
--base <REF>(repeatable) and--head <REF>--staged--diff-file <PATH|->
Policy and filtering:
--scope added|changed|modified|deleted--fail-on error|warn|never--max-findings <N>--paths <GLOB>(repeatable)--only-tags/--enable-tags/--disable-tags--language <LANG>(force preprocessing language)--blame-author/--blame-max-age-days
Outputs:
--out(JSON receipt)--md--sarif--junit--csv/--tsv--sensor--rule-stats--false-positive-baseline--write-false-positive-baseline--trend-history/--trend-max-runs--github-annotations
Exit Codes
Stable exit code contract in standard mode:
0pass1tool/runtime error2policy fail3warn-fail (whenfail_on=warn)
--mode cockpit changes behavior to integration-focused semantics:
0when a receipt is successfully written1only on catastrophic failure
Presets
diffguard init --preset ... supports:
minimalrust-qualitysecretsjs-consolepython-debug
License
Licensed under either of Apache License, Version 2.0 or MIT license at your option.
Dependencies
~11–17MB
~222K SLoC