comply
Check and enforce the REUSE Specification for software licensing -- a command-line tool and the library behind it. A native implementation rather than a port of the Python reuse-tool, reading only the project tree it is pointed at.
That installs a single binary, comply. The same crate is the library: depend
on it with default-features = false to drop clap, anyhow and chrono and keep
only the compliance engine.
[]
= { = "0.0.1", = false }
Commands
| Command | Purpose |
|---|---|
init |
Initialize a project for REUSE compliance |
format |
Format SPDX headers consistently |
lint |
Check a project for REUSE compliance |
lint-file |
Check individual files for REUSE compliance |
annotate |
Add or update SPDX headers |
fix |
Auto-fix compliance issues |
download |
Fetch license texts into LICENSES/ |
spdx |
Generate an SPDX 2.1 bill of materials |
convert-dep5 |
Convert .reuse/dep5 into an equivalent REUSE.toml |
supported-licenses |
List the SPDX identifiers this build recognizes |
init
Creates a REUSE.toml manifest and a LICENSES/ directory. --config-name
selects the manifest spelling (REUSE.toml, reuse.toml, .reuse.toml) and
--force overwrites an existing one.
lint
Output format is chosen with --plain (default), --json, --lines, or
--quiet. Exit codes: 0 = compliant, 1 = non-compliant.
lint-file
Judges only the files named. Output is --lines by default, or --quiet to
rely on the exit code alone. Paths outside the covered set are skipped rather
than reported as failures.
annotate
# Recurse, merging duplicate copyright lines
# Year ranges, and a companion file instead of an inline header
--license and --copyright are optional when REUSE.toml already supplies
them. --copyright-prefix selects the notice style (spdx, spdx-c,
spdx-symbol, string, symbol), and --skip-unrecognised passes over files
whose comment syntax comply does not know.
format
Normalizes header ordering, comment style, and whitespace. --check reports
without writing, for use as a CI gate. Note that format takes --path; it
has no positional argument.
fix
Fixes missing headers, missing license files, and missing .license
companions.
download
Writes license texts into LICENSES/, or into --output. --source takes a
URL or path template in which {} is replaced with the identifier, which is
also how the test suite stays offline.
spdx
convert-dep5
supported-licenses
Configuration
comply reads its own settings from a [tool.comply] table in REUSE.toml.
Everything here is optional.
[]
# Glob patterns comply never looks at, on top of the built-in exclusions
# (.git, target, node_modules, LICENSES/, .reuse/, and so on).
= ["**/target/**", "**/*.lock"]
[]
# Each switch overrides one traversal default. Anything left out keeps the
# default shown here.
= false # true skips dotfiles
= true # apply .gitignore files
= true # apply the user's global excludes file
= true # apply .git/info/exclude
= false # true applies gitignore rules only inside a repository
= false # true follows symlinks
Gitignore rules are layered in git's own precedence order, lowest first:
core.excludesFile, then .git/info/exclude, then every .gitignore from the
project root down to the file's own directory. Because they share one matcher, a
!negation in the repository's .gitignore overrides the global excludes file,
exactly as it does for git.
Typical workflow
Library
| Module | Description |
|---|---|
config |
REUSE.toml and .reuse/dep5 parsing, annotation matching |
error |
Typed error enum built with thiserror |
file |
Discovery, classification, .license companions, exclusion |
fix |
Auto-repair of missing headers and license files |
hash |
SHA-256 integrity hashing |
header |
SPDX header detection, parsing, generation, annotation |
license |
Bundled SPDX License List 3.28, project license audit |
report |
Lint reports and SPDX bill-of-materials generation |
reuse_toml |
REUSE.toml serialization |
scope |
Single source of truth for which paths are covered |
spdx |
SPDX expression parser and validator |
Validate an SPDX expression:
validate?;
assert!;
# Ok::
Read SPDX tags out of file contents:
use header;
let source = "// SPDX-FileCopyrightText: 2026 Acme Inc\n\
// SPDX-License-Identifier: MIT\n";
let found = detect.expect;
assert_eq!;
assert_eq!;
Check an identifier against the bundled license list:
let db = standard_db;
assert!;
assert!;
Walk a project and build a report:
use Config;
use ;
let root = new;
let config = builder.build;
let mut builder = builder;
for entry in walk
let report = builder.build;
println!;
# Ok::
Sharing the covered-path definition
scope is public so a sibling tool can agree with comply about what counts as
a project file without copying the lists -- copies drift, and a stale copy
means a file in a virtualenv gets asked for an SPDX header:
use ;
assert!;
assert!;
assert!;
Features
| Feature | Default | Description |
|---|---|---|
cli |
yes | The comply binary and its clap/anyhow/chrono dependencies |
license-db-network |
no | Fetch the license list at runtime (not yet implemented) |
The SPDX License List is always bundled; it is not a feature. Switching it off could only produce a library unable to validate an identifier against anything.
License
MIT OR Apache-2.0