reuse
Reuse boilerplate code across projects easily
TLDR
Lint for REUSE compliance for the current project (version control aware)
Lint for REUSE compliance from the specified directory
Add copyright statement to file
Add licence information to file
Download a license by its SPDX identifier and place it in the LICENSES directory
Download all missing licenses detected in the project
SYNOPSIS
reuse [options] lint [paths...]
reuse [options] addheader [-l ID | -c TEXT | -H TEXT | -y YEARS | --single-line | --template | --merge-copyrights] files...
reuse [options] addlicense license_id [output_dir]
reuse [options] download
reuse [options] init
reuse [options] spdx [paths...]
reuse help [command]
reuse version
PARAMETERS
--help, -h
Display help information for the command or a specific subcommand.
--version
Show the version number of the reuse tool.
--verbose, -v
Increase the verbosity of the output.
--quiet, -q
Suppress all output except for errors.
lint
Checks project files for REUSE specification compliance, identifying missing headers or license texts.
addheader files...
Adds copyright and license headers to specified files, automatically detecting comment styles.
addlicense license_id
Downloads and adds a full license text file (e.g., GPL-3.0-or-later) to the project's LICENSES/ directory.
download
Downloads all missing license texts required by the project based on detected SPDX license identifiers.
init
Initializes a new project for REUSE compliance, creating necessary directories and configuration files.
spdx
Generates a SPDX Bill of Materials (BOM) for the project, summarizing licensing information in a standard format.
--license
Specify the SPDX license identifier (e.g., GPL-3.0-or-later) for the header. (Used with addheader)
--copyright
Add a custom copyright statement to the header. (Used with addheader)
--holder
Specify the copyright holder for the header. (Used with addheader)
--year
Specify the copyright years (e.g., 2023 or 2020-2023) for the header. (Used with addheader)
--single-line
Add a compact, single-line copyright and license header where possible. (Used with addheader)
--merge-copyrights
Merge existing copyright lines when adding headers to avoid duplicates. (Used with addheader)
DESCRIPTION
The `reuse` command-line tool implements the REUSE Specification, a set of best practices for declaring software licenses and copyrights within a project. Developed by the Free Software Foundation Europe (FSFE), the REUSE Specification aims to make it easy for humans and machines to understand how a project is licensed by standardizing the placement and content of licensing information.
The `reuse` tool helps developers comply with this specification by providing functionalities to lint a project for compliance issues, automatically add copyright and license headers to files, integrate full license texts, and manage licensing metadata. It simplifies the process of ensuring that every file in a project explicitly states its copyright holder and license, thereby improving legal clarity and promoting open-source principles. The tool is particularly useful for projects that integrate various components with different licenses, helping to prevent licensing ambiguities and facilitate proper attribution.
CAVEATS
The `reuse` command is not a standard pre-installed Linux utility; it typically needs to be installed separately, commonly via Python's package manager (pip). Its primary use case is within software development projects to manage licensing information, rather than general system administration or file manipulation. Users should have a basic understanding of the REUSE Specification to effectively utilize the tool. As it modifies files (e.g., adding headers), it is highly recommended to use it within a version-controlled environment (e.g., Git) to prevent unintended data loss or irreversible changes.
REUSE SPECIFICATION
The `reuse` tool strictly adheres to the REUSE Specification (version 3.0), which dictates how licensing and copyright information should be stored within a project. This includes requirements for a LICENSES/ directory for full license texts, license identifiers in file headers, and optional .reuse/dep5 files for package-level metadata.
INTEGRATION WITH WORKFLOWS
Due to its command-line nature, `reuse` can be easily integrated into continuous integration/continuous deployment (CI/CD) pipelines. This allows for automated checks of REUSE compliance with every commit or build, ensuring that license information remains consistent and correct throughout the project's lifecycle.
SUPPORTED FILE TYPES
The tool supports a wide variety of programming languages and file types, automatically detecting the appropriate comment style for adding headers based on file extensions or shebang lines. This broad compatibility ensures that licensing information can be uniformly applied across diverse codebases.
HISTORY
The `reuse` tool is an implementation of the REUSE Specification, which was developed by the Free Software Foundation Europe (FSFE). The specification was first publicly launched around 2017-2018 with the goal of providing a clear, standardized, and machine-readable way to declare licensing and copyright information within software projects. The tool itself was developed concurrently to help projects automatically comply with these guidelines, addressing the growing complexity of licensing in modern software development where components from various sources with differing licenses are often integrated. Its development was driven by the need to simplify auditing, enhance legal clarity, and promote proper attribution in open-source software.