Giter Club home page Giter Club logo

license's Introduction

license is a command line tool to create LICENSE files.

It provides good defaults for name, year and project name on license (customizable if needed), and it supports all license types listed on the GitHub Licenses API and a few more. The license templates used by this program were copied from the GitHub Licenses API, when available.

afl-3.0       (Academic Free License)
agpl-3.0      (GNU Affero General Public License v3.0)
al-2.0        (Artistic License 2.0)
apache-2.0    (Apache License 2.0)
bsd-0-clause  (BSD Zero Clause License)
bsd-2-clause  (BSD 2-Clause "Simplified" License)
bsd-3-clause  (BSD 3-Clause "New" or "Revised" License)
bsd-4-clause  (BSD 4-clause "Original" or "Old" License)
cc-by-4.0     (CC-BY 4.0 International Public License)
cc-by-sa-4.0  (CC-BY-SA 4.0 International Public License)
cc0-1.0       (Creative Commons Zero v1.0 Universal)
ecl-2.0       (Educational Community License 2.0)
epl-2.0       (Eclipse Public License 2.0)
eupl-1.2      (European Union Public Licence 1.2)
free-art-1.3  (Free Art License 1.3)
gpl-2.0       (GNU General Public License v2.0)
gpl-3.0       (GNU General Public License v3.0)
isc           (ISC License)
lgpl-2.1      (GNU Lesser General Public License v2.1)
lgpl-3.0      (GNU Lesser General Public License v3.0)
lppl          (LaTeX Project Public License)
mit           (MIT License)
mit-0         (MIT No Attribution)
mpl-2.0       (Mozilla Public License 2.0)
ms-pl         (Microsoft Public License)
ms-rl         (Microsoft Reciprocal License)
mulanpsl-2.0  (木兰宽松许可证 第2版)
odbl-1.0      (ODC Open Database License 1.0)
ofl-1.1       (SIL OPEN FONT LICENSE Version 1.1)
osl-3.0       (Open Software License v3.0)
unlicense     (The Unlicense)
wtfpl         (Do What The Fuck You Want To Public License)
zlib          (zlib License)

Install

Building from Source

With Go 1.16 or higher:

go install github.com/nishanths/license/v5@latest

Via the Arch User Repository (AUR)

This program is available via the AUR under the name nishanths-license-git. Using yay, you can install it like so:

WARNING: The authenticity of this method was last verified on 2021-07-04 by the maintainer(s) of the license project. Please verify before use.

yay -S nishanths-license-git

Usage

Print license

To print a license to stdout, run the license command followed by the license name:

$ license mit

Save to file

Use the -o flag to save the license to a file, or use your shell's redirection operator:

$ license -o LICENSE.txt mit
$ license mit > LICENSE.txt

Customize name, year and project name

$ license -year 2013 -name "Alice L" isc
$ license -name "Alice L" -year 2022 -project "myapp" bsd-4-clause

The current year is used if -year is omitted.

The current folder is used as the project name if -project is omitted.

To determine the name on the license, the following are used in this order:

- command line flags: -name, -n
- environment variable: LICENSE_FULL_NAME
- gitconfig and hgconfig
- "os/user".Current()
- empty string

If you have your name set in $HOME/.gitconfig, you can almost always omit the -name flag.

Demo

Demonstration

Contributing

Pull requests for new features, bug fixes, and suggestions are welcome! Please create an issue for discussion before working on a substantial change.

License

MIT

license's People

Contributors

adriangrigore avatar e1mo avatar eldersjavas avatar giraffekey avatar josephlin55555 avatar nishanths avatar olavfosse avatar twelvelabs avatar waldyrious avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

license's Issues

Missing ISC license

The README mentions the ISC license, although as far as I can see it was never supported.

image

I can open a PR to add it, or was there a reason it was removed?

Position of the arguments can cause app to ignore arguments

Summary

Position of the arguments can cause app to ignore arguments. If the arguments -o LICENSE are placed after the license name then they are ignored.

What I expected to happen

I expected the following command when executed would output the license into the file LICENSE.

license mit -o LICENSE

What happened

The license was outputted to stdout and the LICENSE file was not written.

Use Go 1.16 embed rather than go-bindata

Concept

As of Go 1.16, the embed package allows embedding arbitrary files into variables in code. I think that using this built in rather than depending on an external tool like go-bindata is nicer and the code itself is much cleaner and easier to read.

Rationale

The way that embed works is by adding a directive comment with the target file's path above a variable declaration, such as a string or byte slice, and the compiler sets that variable to the contents of that file at build time. This is basically what we do now when we regenerate templates.go with go-bindata, however, embed has two main advantages over go-bindata:

  1. embed is a part of the build. This makes it easier for new contributors as using go-bindata wasn't really obvious to me when I was making my first contribution here.
  2. Adding or updating licenses becomes as simple as editing the .txt file in question, with no code changes needed. Where as we currently need to regenerate templates.go.

Design

I've been meaning to add this since I read about embed in the release notes so I'll probably make a prototype on my fork at some point. I just wanted to feel out if this would be wanted / if there are any design considerations to make.

Pre-built binaries

Would you be interested in providing pre-built binaries? I'm currently looking at bundling this tool in a few non-golang based Docker images, and having it pre-built would be really convenient.

If so, I might try and submit a PR w/ a GoReleaser + GH actions config.

Problem with separate partitions

When having /home and /tmp on separate partitions, I get:

rename /tmp/license-388690913 /home/jD91mZM2/.license: invalid cross-device link

This is because you can't rename across partitions. When renaming fails with this error you should fallback to copying and deleting the original.

Install problem — undefined: os.LookupEnv

$  go get github.com/nishanths/license
# github.com/nishanths/license/base
projects/golang/src/github.com/nishanths/license/base/config.go:24: undefined: os.LookupEnv

Running Debian Jessie with golang package version 2:1.3.3-1.

adjust `Go / fmt (pull_request)` check

Firstly, the check auto-formats and auto-commits changes to branches. This is behavior I tend to not like. We should modify the check to only check that the code is formatted. It should not auto-commit any changes.

Secondly, it seems to fail when run on a PR for branches on other remotes. For example, see this run.

Cannot get latest version: module contains a go.mod file, so module path should be github.com/nishanths/license/v2

Background

The github.com/nishanths/license uses Go modules and the current release version is v2. And it’s module path is "github.com/nishanths/license", instead of "github.com/nishanths/license/v2". It must comply with the specification of "Releasing Modules for v2 or higher" available in the Modules documentation. Quoting the specification:

A package that has opted in to modules must include the major version in the import path to import any v2+ modules
To preserve import compatibility, the go command requires that modules with major version v2 or later use a module path with that major version as the final element. For example, version v2.0.0 of example.com/m must instead use module path example.com/m/v2.
https://github.com/golang/go/wiki/Modules#releasing-modules-v2-or-higher

Steps to Reproduce

GO111MODULE=on, run go get targeting any version >= v2.0.0 of the nishanths/license:

$ go get github.com/nishanths/[email protected]
go: finding github.com/nishanths/license v2.0.0
go: finding github.com/nishanths/license v2.0.0
go get github.com/nishanths/[email protected]: github.com/nishanths/[email protected]: invalid version: module contains a go.mod file, so major version must be compatible: should be v0 or v1, not v2

run go get github.com/nishanths/license, the version will stuck in v1.0.0:

$go get github.com/nishanths/license
go: downloading github.com/nishanths/license v1.0.0
go: github.com/nishanths/license upgrade => v1.0.0

SO anyone using Go modules will not be able to easily use any newer version of nishanths/license.

Solution

1. Kill the go.mod files, rolling back to GOPATH.

This would push them back to not being managed by Go modules (instead of incorrectly using Go modules).
Ensure compatibility for downstream module-aware projects and module-unaware projects projects

I see these dependencies in your go.mod file, which need modle awareness. So you'd better not use third-party tools(such as: Dep, glide, govendor…).

github.com/nishanths/license/v5

You also need to update the import path to:

import github.com/nishanths/license/…

2. Fix module path to strictly follow SIV rules.

Patch the go.mod file to declare the module path as github.com/nishanths/license/v2 as per the specs. And adjust all internal imports.
The downstream projects might be negatively affected in their building if they are module-unaware (Go versions older than 1.9.7 and 1.10.3; Or use third-party dependency management tools, such as: Dep, glide,govendor…).

[*] You can see who will be affected here: [2 module-unaware users, i.e., PhoneSecurity2381/License-Agreement, jspc/mkrepo, ]
https://github.com/search?l=Go&p=2&q=nishanths%2Flicense&type=Code

If you don't want to break the above repos. This method can provides better backwards-compatibility.
Release a v2 or higher module through the major subdirectory strategy: Create a new v2 subdirectory (github.com/nishanths/license/v2) and place a new go.mod file in that subdirectory. The module path must end with /v2. Copy or move the code into the v2 subdirectory. Update import statements within the module to also use /v2 (import "github.com/nishanths/license/v2/…"). Tag the release with v2.x.y.

3. Major version bump / repository change

Leave v2 as a dead version and bump to v3 with the path changes.

4. Suggest your downstream module users use hash instead of a version tag.

If the standard rule of go modules conflicts with your development mode. Or not intended to be used as a library and does not make any guarantees about the API. So you can’t comply with the specification of "Releasing Modules for v2 or higher" available in the Modules documentation.
Regardless, since it's against one of the design choices of Go, it'll be a bit of a hack. Instead of go get github.com/nishanths/license@version-tag, module users need to use this following way to get the nishanths/license:
(1) Search for the tag you want (in browser)
(2) Get the commit hash for the tag you want
(3) Run go get github.com/nishanths/license@commit-hash
(4) Edit the go.mod file to put a comment about which version you actually used
This will make it difficult for module users to get and upgrade nishanths/license.

Summary

You can make a choice to fix DM issues by balancing your own development schedules/mode against the affects on the downstream projects.

For this issue, Solution 1 can maximize your benefits and with minimal impacts to your downstream projects the ecosystem.

References

Vendor Obsolete

I clone the repo then run:
cd license; go mod tidy; go build

which gives following error:

go: inconsistent vendoring in /Users/kendfss/gitclone/clones/nishanths/license:
	github.com/onsi/[email protected]: is explicitly required in go.mod, but not marked as explicit in vendor/modules.txt

	To ignore the vendor directory, use -mod=readonly or -mod=mod.
	To sync the vendor directory, run:
		go mod vendor

And when I ignore (i just removed the vendor directory), it built and works normally.
I think since the readme recommends go install and any version of go that supports install supports modules, the vendor directory isn't useful anymore.

Revise GitHub Pages with newer install command

Installed through go install on Debian Bookworm (testing) (go 1.17) and added ~/go/bin to my PATH via .bashrc since this is my first time using the go install system. When I tried to run it I got the following error:

$ license gpl-3.0 -o LICENCE.txt
rename /tmp/license-349994170 /home/[REDACTED]/.license: invalid cross-device link

The directory ~/.license doesn't exist, which seems like it may be an installation problem. If so, I may need a bit of help with installation instructions. If not, my system is partitioned with separate partitions for / and /home, so my guess is this may be the cause of the issue; that or problems with the /tmp filesystem which resides in memory.

GPL Licenses doesn't works

~
❯ license gpl-3.0
html/template:gpl-3.0.tmpl: "'" in attribute name: "program's name and a brief idea "

~
❯ license gpl-2.0
html/template:gpl-2.0.tmpl: "'" in attribute name: "program's name and a brief idea "

license package version: v1.0.1
go version: go 1.9.2

Getting "Error: Empty installation" for Homebrew install

Hi there,

I was trying to install this package via Homebrew, and followed all the steps, however, on the last step where it actually installs the package, I got the following error:

==> Installing license from nishanths/tap
==> Downloading https://storage.googleapis.com/license-binaries/darwin_amd64/0.1.2/license.tar.gz
######################################################################## 100.0%
Error: Empty installation

Any ideas?

Invalid Cross-Device Link

I'm on Linux kernel 5.4, running elementary OS 5.0, which is Ubuntu 18.04, amd64 architecture.

When I run the CLI, I get the following error:

$ license -o LICENSE-APACHE apache2
rename /tmp/license-247108171 /home/naftuli/.license: invalid cross-device link

/home/ and /tmp/ live on different filesystems. I assume that this issue is caused by trying to hard-link rather than by trying to create a new file and write data to it.

flags and GNU GPL

Hi,

When I use

license --name COLUNDRUM --year 2016 gpl-3.0

The output is the original license without customization about project title, name and year.

Same issue with

  • agpl-3.0
  • apache-2.0
  • gpl-2.0
  • lgpl-2.1
  • lgpl-3.0

Thanks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.