cmd: Refine formatting of included licenses

This commit is contained in:
Anthony Fok 2017-07-30 02:35:06 -06:00
parent a1b7d3cc4d
commit 9e024b655b
10 changed files with 22 additions and 30 deletions

View File

@ -121,8 +121,7 @@ func validateCmdName(source string) string {
func createCmdFile(license License, path, cmdName string) { func createCmdFile(license License, path, cmdName string) {
template := `{{comment .copyright}} template := `{{comment .copyright}}
{{if .license}}// {{if .license}}{{comment .license}}{{end}}
{{comment .license}}{{end}}
package {{.cmdPackage}} package {{.cmdPackage}}

View File

@ -107,8 +107,7 @@ func createLicenseFile(license License, path string) {
func createMainFile(project *Project) { func createMainFile(project *Project) {
mainTemplate := `{{ comment .copyright }} mainTemplate := `{{ comment .copyright }}
{{if .license}}// {{if .license}}{{ comment .license }}{{end}}
{{ comment .license }}{{end}}
package main package main
@ -136,8 +135,7 @@ func main() {
func createRootCmdFile(project *Project) { func createRootCmdFile(project *Project) {
template := `{{comment .copyright}} template := `{{comment .copyright}}
{{if .license}}// {{if .license}}{{comment .license}}{{end}}
{{comment .license}}{{end}}
package cmd package cmd

View File

@ -4,8 +4,7 @@ func initAgpl() {
Licenses["agpl"] = License{ Licenses["agpl"] = License{
Name: "GNU Affero General Public License", Name: "GNU Affero General Public License",
PossibleMatches: []string{"agpl", "affero gpl", "gnu agpl"}, PossibleMatches: []string{"agpl", "affero gpl", "gnu agpl"},
Header: `{{.copyright}} Header: `
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or the Free Software Foundation, either version 3 of the License, or

View File

@ -19,7 +19,8 @@ func initApache2() {
Licenses["apache"] = License{ Licenses["apache"] = License{
Name: "Apache 2.0", Name: "Apache 2.0",
PossibleMatches: []string{"apache", "apache20", "apache 2.0", "apache2.0", "apache-2.0"}, PossibleMatches: []string{"apache", "apache20", "apache 2.0", "apache2.0", "apache-2.0"},
Header: `Licensed under the Apache License, Version 2.0 (the "License"); Header: `
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
You may obtain a copy of the License at You may obtain a copy of the License at

View File

@ -20,8 +20,7 @@ func initBsdClause2() {
Name: "Simplified BSD License", Name: "Simplified BSD License",
PossibleMatches: []string{"freebsd", "simpbsd", "simple bsd", "2-clause bsd", PossibleMatches: []string{"freebsd", "simpbsd", "simple bsd", "2-clause bsd",
"2 clause bsd", "simplified bsd license"}, "2 clause bsd", "simplified bsd license"},
Header: ` Header: `All rights reserved.
All rights reserved.
Redistribution and use in source and binary forms, with or without Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met: modification, are permitted provided that the following conditions are met:

View File

@ -19,8 +19,7 @@ func initBsdClause3() {
Licenses["bsd"] = License{ Licenses["bsd"] = License{
Name: "NewBSD", Name: "NewBSD",
PossibleMatches: []string{"bsd", "newbsd", "3 clause bsd", "3-clause bsd"}, PossibleMatches: []string{"bsd", "newbsd", "3 clause bsd", "3-clause bsd"},
Header: ` Header: `All rights reserved.
All rights reserved.
Redistribution and use in source and binary forms, with or without Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met: modification, are permitted provided that the following conditions are met:

View File

@ -19,20 +19,19 @@ func initGpl2() {
Licenses["gpl2"] = License{ Licenses["gpl2"] = License{
Name: "GNU General Public License 2.0", Name: "GNU General Public License 2.0",
PossibleMatches: []string{"gpl2", "gnu gpl2", "gplv2"}, PossibleMatches: []string{"gpl2", "gnu gpl2", "gplv2"},
Header: `{{.copyright}} Header: `
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 2
of the License, or (at your option) any later version.
This program is free software; you can redistribute it and/or This program is distributed in the hope that it will be useful,
modify it under the terms of the GNU General Public License but WITHOUT ANY WARRANTY; without even the implied warranty of
as published by the Free Software Foundation; either version 2 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
of the License, or (at your option) any later version. GNU General Public License for more details.
This program is distributed in the hope that it will be useful, You should have received a copy of the GNU Lesser General Public License
but WITHOUT ANY WARRANTY; without even the implied warranty of along with this program. If not, see <http://www.gnu.org/licenses/>.`,
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 Lesser General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.`,
Text: ` GNU GENERAL PUBLIC LICENSE Text: ` GNU GENERAL PUBLIC LICENSE
Version 2, June 1991 Version 2, June 1991

View File

@ -19,8 +19,7 @@ func initGpl3() {
Licenses["gpl3"] = License{ Licenses["gpl3"] = License{
Name: "GNU General Public License 3.0", Name: "GNU General Public License 3.0",
PossibleMatches: []string{"gpl3", "gplv3", "gpl", "gnu gpl3", "gnu gpl"}, PossibleMatches: []string{"gpl3", "gplv3", "gpl", "gnu gpl3", "gnu gpl"},
Header: `{{.copyright}} Header: `
This program is free software: you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or the Free Software Foundation, either version 3 of the License, or

View File

@ -4,8 +4,7 @@ func initLgpl() {
Licenses["lgpl"] = License{ Licenses["lgpl"] = License{
Name: "GNU Lesser General Public License", Name: "GNU Lesser General Public License",
PossibleMatches: []string{"lgpl", "lesser gpl", "gnu lgpl"}, PossibleMatches: []string{"lgpl", "lesser gpl", "gnu lgpl"},
Header: `{{.copyright}} Header: `
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or the Free Software Foundation, either version 3 of the License, or

View File

@ -17,7 +17,7 @@ package cmd
func initMit() { func initMit() {
Licenses["mit"] = License{ Licenses["mit"] = License{
Name: "Mit", Name: "MIT License",
PossibleMatches: []string{"mit"}, PossibleMatches: []string{"mit"},
Header: ` Header: `
Permission is hereby granted, free of charge, to any person obtaining a copy Permission is hereby granted, free of charge, to any person obtaining a copy