https://github.com/sudorook/licensetool
Tool for embedding SPDX metadata and license blurbs in files. Uses fsfe/reuse-tool.
https://github.com/sudorook/licensetool
license license-management reuse spdx
Last synced: 2 months ago
JSON representation
Tool for embedding SPDX metadata and license blurbs in files. Uses fsfe/reuse-tool.
- Host: GitHub
- URL: https://github.com/sudorook/licensetool
- Owner: sudorook
- Created: 2024-04-27T05:04:00.000Z (about 1 year ago)
- Default Branch: master
- Last Pushed: 2024-12-16T02:21:43.000Z (6 months ago)
- Last Synced: 2025-02-01T03:11:22.424Z (4 months ago)
- Topics: license, license-management, reuse, spdx
- Language: Jinja
- Homepage:
- Size: 46.9 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSES/GPL-3.0-or-later.txt
Awesome Lists containing this project
README
# License Tool
Tool for adding license information to a repository. Useful for inserting
SPDX-compliant license headers to files, including any relevant license-specific
header text, via [reuse-tool](https://github.com/fsfe/reuse-tool).The main attraction of this script over using `reuse annotate` directly is the
ability to fill fields directly from Git metadata.Also included are custom license templates (see
`.reuse/templates/header.jinja2`) that not only set the SPDX standard fields but
also adds the copyright blurbs for licenses that include them.For example, setting a GPLv3 header will embed:
```txt
SPDX-FileCopyrightText:SPDX-License-Identifier: GPL-3.0-or-later
This program is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the Free
Software Foundation, either version 3 of the License, or (at your option)
any later version.This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.You should have received a copy of the GNU General Public License along
with this program. If not, see .
```**IMPORTANT:** As of writing, `reuse-tool` requires that header templates exist
at the root of the project directory. The presence
`.reuse/templates/header.jinja2` is a requirement for this script to work so
either:1. Copy `.reuse/` from this repository to the base of each project.
2. Use [my fork](https://github.com/sudorook/reuse-tool) of reuse which uses
`python-appdirs` to read templates from a global location. (On Linux, copy
`.reuse/` to `~/.local/share/reuse`.)## Embed SPDX metadata
To embed SPDX license metadata, run:
```sh
licensetool annotate
```The available flags are:
```txt
-a|--author author (optional)
-e|--email email address (optional)
-g|--git fill optional fields using Git metadata
-l|--license license header to embed (required)
-y|--year year for copyright notice (optional)
-s|--style 'reuse' copyright style (default: spdx)
-m|--multiline force multiline comments for header (default: false)"
```Multiple authors, email addresses, years, and licenses can be supplied by
passing comma-delimited strings.The `license` field may be supplied via the command line, and if not specified,
the script will prompt the user for a selection.All of the optional fields can be automatically filled using Git commit data if
the `-g` flag is passed to the script. The `year` field will default to the
current year if not deduced through Git metadata.Lastly, the `-s` flag refers to the copyright style. The options are:
- `spdx`
- `spdx-c`
- `spdx-string-c`
- `spdx-string`
- `spdx-string-symbol`
- `spdx-symbol`
- `string`
- `string-c`
- `string-symbol`
- `symbol`See `reuse annotate --help` for more information.
## Download licenses
To download the license(s) specified in the headers, run:
```sh
licensetool download
```This is a simple wrapper around `reuse download --all`.