~zethra/license

Bump version to 3.1.0
Add flake info to README
_incr_version script sets flake version

clone

read-only
https://git.sr.ht/~zethra/license
read/write
git@git.sr.ht:~zethra/license

You can also use your local clone with git send-email.

#License

A cli tool to easily add a license to your project.

Image of program usage

license prints out the text of the selected license. All of the license texts and baked into the binary, so it has no external dependencies, nor does it have to fetch them over the network. This has the downside that the user cannot add licenses without recompiling the program. license can also print the headers for licenses the have them.

license with also insert various fields into the license text, such as the project and author's names. It will attempt to derive these from various sources. Failing that the user will be prompted for the missing fields.

Gif showing the program in use

I've also written some scripts that use fzf with license. This is way I use it. Both scripts will pipe the license list into fzf then put the chosen license name is given back license. set-license pipes the text of the selected license into a file called LICENSE in the current directory. copy-header copies the selected license header into the clipboard using xclip on X.org and wl-copy on Wayland. It take the comment string as the first argument.

#Nix Flake

Run via nix run sourcehut:~zethra/license/<desired tag>

Or install

# Flake inputs
license.url = "sourcehut:~zethra/license/<desired tag>";

# In NixOS config
environment.systemPackages = [
    (license.packages.${system})
];

See my NixOS config as an example

#Build

Requires rustc 1.64.0 or greater.

cargo build --release
scdoc < doc/license.scd > license.1

#Install

install -D -m755 "target/release/license" "/usr/bin/license"
install -D -m755 "scripts/set-license" "/usr/bin/set-license"
install -D -m755 "scripts/copy-header" "/usr/bin/copy-header"
install -D -m644 "LICENSE" "/usr/share/licenses/license/LICENSE"
install -D -m644 "license.1" "/usr/share/man/man1/license.1"

install -D -m644 "completions/license.bash" \
                 "/usr/share/bash-completion/completions/license"
install -D -m644 "completions/_license" \
                 "/usr/share/zsh/site-functions/_license"
install -D -m644 "completions/license.fish" \
                 "/usr/share/fish/vendor_completions.d/license.fish"

#Usage

license 1.0.0
A cli tool to easily add a license to your project

USAGE:
    license [FLAGS] <SUBCOMMAND>

FLAGS:
    -h, --help       Prints help information
    -V, --version    Prints version information
    -v, --verbose    Print addition debugging information

SUBCOMMANDS:
    header    Print the header text for a license
    help      Prints this message or the help of the given subcommand(s)
    list      List available license names
    text      Print the text of a license

#Available Licenses

0BSD
AGPL-3.0-only
AGPL-3.0-or-later
Apache-2.0
Artistic-2.0
BSD-1-Clause
BSD-2-Clause
BSD-3-Clause
CC-BY-1.0
CC-BY-2.0
CC-BY-2.5
CC-BY-3.0
CC-BY-4.0
CC-BY-NC-3.0
CC-BY-NC-4.0
CC-BY-NC-ND-3.0
CC-BY-NC-ND-4.0
CC-BY-NC-SA-3.0
CC-BY-NC-SA-4.0
CC-BY-ND-3.0
CC-BY-ND-4.0
CC-BY-SA-3.0
CC-BY-SA-4.0
CC-PDDC
CC0-1.0
CNPL-7.0
CNPL-7.0-or-later
CNPL-NA-7.0
CNPL-NA-7.0-or-later
EUPL-1.2
FSFAP
GFDL-1.3-invariants-only
GFDL-1.3-invariants-or-later
GFDL-1.3-no-invariants-only
GFDL-1.3-no-invariants-or-later
GFDL-1.3-only
GFDL-1.3-or-later
GPL-2.0-only
GPL-2.0-or-later
GPL-3.0-only
GPL-3.0-or-later
Hippocratic-2.1
ISC
LGPL-2.0-only
LGPL-2.0-or-later
LGPL-2.1-only
LGPL-2.1-or-later
LGPL-3.0-only
LGPL-3.0-or-later
MIT
MPL-1.0
MPL-1.1
MPL-2.0
MPL-2.0-no-copyleft-exception
NVPL-7.0
NVPL-7.0-or-later
NVPL-NA-7.0
NVPL-NA-7.0-or-later
Unlicense
WTFPL
X11

#Contributing

Please send any and all patches, bugs, and questions to my public inbox ~zethra/public-inbox@lists.sr.ht or submit a ticket to the bug tracker if you feel so inclined todo.sr.ht/~zethra/license.

If you'd like to add I license please add a file named the license's name containing the content of the license. If the license has a header that goes with it also add a file called <license name>-header containing the content of the header.

If the license has fields in it please add template strings for them. The template strings are in the format {{field_name}}. The currently support template items are:

  • copyright_year
  • author
  • project_name
  • description