From 9e024b655b62b4fc14d3f6920f35a65cf38ac898 Mon Sep 17 00:00:00 2001 From: Anthony Fok Date: Sun, 30 Jul 2017 02:35:06 -0600 Subject: [PATCH] cmd: Refine formatting of included licenses --- cobra/cmd/add.go | 3 +-- cobra/cmd/init.go | 6 ++---- cobra/cmd/license_agpl.go | 3 +-- cobra/cmd/license_apache_2.go | 3 ++- cobra/cmd/license_bsd_clause_2.go | 3 +-- cobra/cmd/license_bsd_clause_3.go | 3 +-- cobra/cmd/license_gpl_2.go | 23 +++++++++++------------ cobra/cmd/license_gpl_3.go | 3 +-- cobra/cmd/license_lgpl.go | 3 +-- cobra/cmd/license_mit.go | 2 +- 10 files changed, 22 insertions(+), 30 deletions(-) diff --git a/cobra/cmd/add.go b/cobra/cmd/add.go index c97ce844..30f83662 100644 --- a/cobra/cmd/add.go +++ b/cobra/cmd/add.go @@ -121,8 +121,7 @@ func validateCmdName(source string) string { func createCmdFile(license License, path, cmdName string) { template := `{{comment .copyright}} -{{if .license}}// -{{comment .license}}{{end}} +{{if .license}}{{comment .license}}{{end}} package {{.cmdPackage}} diff --git a/cobra/cmd/init.go b/cobra/cmd/init.go index 2338b4fc..149aabe1 100644 --- a/cobra/cmd/init.go +++ b/cobra/cmd/init.go @@ -107,8 +107,7 @@ func createLicenseFile(license License, path string) { func createMainFile(project *Project) { mainTemplate := `{{ comment .copyright }} -{{if .license}}// -{{ comment .license }}{{end}} +{{if .license}}{{ comment .license }}{{end}} package main @@ -136,8 +135,7 @@ func main() { func createRootCmdFile(project *Project) { template := `{{comment .copyright}} -{{if .license}}// -{{comment .license}}{{end}} +{{if .license}}{{comment .license}}{{end}} package cmd diff --git a/cobra/cmd/license_agpl.go b/cobra/cmd/license_agpl.go index 4ea036ed..bc22e973 100644 --- a/cobra/cmd/license_agpl.go +++ b/cobra/cmd/license_agpl.go @@ -4,8 +4,7 @@ func initAgpl() { Licenses["agpl"] = License{ Name: "GNU Affero General Public License", PossibleMatches: []string{"agpl", "affero gpl", "gnu agpl"}, - Header: `{{.copyright}} - + Header: ` 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 the Free Software Foundation, either version 3 of the License, or diff --git a/cobra/cmd/license_apache_2.go b/cobra/cmd/license_apache_2.go index 3f330867..38393d54 100644 --- a/cobra/cmd/license_apache_2.go +++ b/cobra/cmd/license_apache_2.go @@ -19,7 +19,8 @@ func initApache2() { Licenses["apache"] = License{ Name: "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 obtain a copy of the License at diff --git a/cobra/cmd/license_bsd_clause_2.go b/cobra/cmd/license_bsd_clause_2.go index f2982dab..4a847e04 100644 --- a/cobra/cmd/license_bsd_clause_2.go +++ b/cobra/cmd/license_bsd_clause_2.go @@ -20,8 +20,7 @@ func initBsdClause2() { Name: "Simplified BSD License", PossibleMatches: []string{"freebsd", "simpbsd", "simple bsd", "2-clause bsd", "2 clause bsd", "simplified bsd license"}, - Header: ` -All rights reserved. + Header: `All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: diff --git a/cobra/cmd/license_bsd_clause_3.go b/cobra/cmd/license_bsd_clause_3.go index 39c9571f..c7476b31 100644 --- a/cobra/cmd/license_bsd_clause_3.go +++ b/cobra/cmd/license_bsd_clause_3.go @@ -19,8 +19,7 @@ func initBsdClause3() { Licenses["bsd"] = License{ Name: "NewBSD", PossibleMatches: []string{"bsd", "newbsd", "3 clause bsd", "3-clause bsd"}, - Header: ` -All rights reserved. + Header: `All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: diff --git a/cobra/cmd/license_gpl_2.go b/cobra/cmd/license_gpl_2.go index 054b470f..03e05b3a 100644 --- a/cobra/cmd/license_gpl_2.go +++ b/cobra/cmd/license_gpl_2.go @@ -19,20 +19,19 @@ func initGpl2() { Licenses["gpl2"] = License{ Name: "GNU General Public License 2.0", 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 - 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 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. - 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 Lesser General Public License - along with this program. If not, see .`, +You should have received a copy of the GNU Lesser General Public License +along with this program. If not, see .`, Text: ` GNU GENERAL PUBLIC LICENSE Version 2, June 1991 diff --git a/cobra/cmd/license_gpl_3.go b/cobra/cmd/license_gpl_3.go index d1ef656a..ce07679c 100644 --- a/cobra/cmd/license_gpl_3.go +++ b/cobra/cmd/license_gpl_3.go @@ -19,8 +19,7 @@ func initGpl3() { Licenses["gpl3"] = License{ Name: "GNU General Public License 3.0", PossibleMatches: []string{"gpl3", "gplv3", "gpl", "gnu gpl3", "gnu gpl"}, - 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 3 of the License, or diff --git a/cobra/cmd/license_lgpl.go b/cobra/cmd/license_lgpl.go index 75fd043b..0f8b96ca 100644 --- a/cobra/cmd/license_lgpl.go +++ b/cobra/cmd/license_lgpl.go @@ -4,8 +4,7 @@ func initLgpl() { Licenses["lgpl"] = License{ Name: "GNU Lesser General Public License", PossibleMatches: []string{"lgpl", "lesser gpl", "gnu lgpl"}, - Header: `{{.copyright}} - + Header: ` 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 the Free Software Foundation, either version 3 of the License, or diff --git a/cobra/cmd/license_mit.go b/cobra/cmd/license_mit.go index 4ff5a4cd..bd2d0c4f 100644 --- a/cobra/cmd/license_mit.go +++ b/cobra/cmd/license_mit.go @@ -17,7 +17,7 @@ package cmd func initMit() { Licenses["mit"] = License{ - Name: "Mit", + Name: "MIT License", PossibleMatches: []string{"mit"}, Header: ` Permission is hereby granted, free of charge, to any person obtaining a copy