mirror of
https://github.com/spf13/cobra
synced 2025-05-05 21:07:24 +00:00
Merge b0ace35ce7
into 4c05eb1145
This commit is contained in:
commit
8985ae80d8
4 changed files with 26 additions and 14 deletions
|
@ -68,6 +68,7 @@ func createCmdFile(cmdName string) {
|
|||
lic := getLicense()
|
||||
|
||||
template := `{{ comment .copyright }}
|
||||
// SPDX-License-Identifier: {{ .licensename }}
|
||||
{{ comment .license }}
|
||||
|
||||
package cmd
|
||||
|
|
|
@ -301,11 +301,13 @@ func getLicense() License {
|
|||
l := whichLicense()
|
||||
if l != "" {
|
||||
if x, ok := Licenses[l]; ok {
|
||||
fmt.Printf("Info: License matched, using %q\n", x.Identifier)
|
||||
return x
|
||||
}
|
||||
}
|
||||
|
||||
return Licenses["apache"]
|
||||
fmt.Println("Info: License not specified or not found, using \"Apache-2.0\"")
|
||||
return Licenses["Apache-2.0"]
|
||||
}
|
||||
|
||||
func whichLicense() string {
|
||||
|
|
|
@ -108,6 +108,7 @@ func createMainFile() {
|
|||
lic := getLicense()
|
||||
|
||||
template := `{{ comment .copyright }}
|
||||
// SPDX-License-Identifier: {{ .licensename }}
|
||||
{{ comment .license }}
|
||||
|
||||
package main
|
||||
|
@ -123,6 +124,7 @@ func main() {
|
|||
|
||||
data["copyright"] = copyrightLine()
|
||||
data["license"] = lic.Header
|
||||
data["licensename"] = lic.Identifier
|
||||
data["importpath"] = guessImportPath() + "/" + guessCmdDir()
|
||||
|
||||
err := writeTemplateToFile(ProjectPath(), "main.go", template, data)
|
||||
|
@ -136,6 +138,7 @@ func createRootCmdFile() {
|
|||
lic := getLicense()
|
||||
|
||||
template := `{{ comment .copyright }}
|
||||
// SPDX-License-Identifier: {{ .licensename }}
|
||||
{{ comment .license }}
|
||||
|
||||
package cmd
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
// Copyright © 2015 Steve Francia <spf@spf13.com>.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
|
@ -25,7 +26,8 @@ var Licenses map[string]License
|
|||
// the header to be used with each file on the file's creating, and the text
|
||||
// of the license
|
||||
type License struct {
|
||||
Name string // The type of license in use
|
||||
Identifier string // SPDX License Identifier
|
||||
Name string // The long name of the license in use
|
||||
PossibleMatches []string // Similar names to guess
|
||||
Text string // License text data
|
||||
Header string // License header for source files
|
||||
|
@ -46,9 +48,10 @@ func matchLicense(in string) string {
|
|||
func init() {
|
||||
Licenses = make(map[string]License)
|
||||
|
||||
Licenses["apache"] = License{
|
||||
Name: "Apache 2.0",
|
||||
PossibleMatches: []string{"apache", "apache20", "apache 2.0", "apache2.0", "apache-2.0"},
|
||||
Licenses["Apache-2.0"] = License{
|
||||
Identifier: "Apache-2.0",
|
||||
Name: "Apache License 2.0",
|
||||
PossibleMatches: []string{"Apache-2.0", "Apache", "Apache-2", "apache20", "Apache 2.0", "Apache2.0"},
|
||||
Header: `
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
|
@ -266,9 +269,10 @@ func init() {
|
|||
`,
|
||||
}
|
||||
|
||||
Licenses["mit"] = License{
|
||||
Name: "Mit",
|
||||
PossibleMatches: []string{"mit"},
|
||||
Licenses["MIT"] = License{
|
||||
Identifier: "MIT",
|
||||
Name: "MIT License",
|
||||
PossibleMatches: []string{"MIT", "Expat"},
|
||||
Header: `
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
@ -311,9 +315,10 @@ THE SOFTWARE.
|
|||
`,
|
||||
}
|
||||
|
||||
Licenses["bsd"] = License{
|
||||
Name: "NewBSD",
|
||||
PossibleMatches: []string{"bsd", "newbsd", "3 clause bsd"},
|
||||
Licenses["BSD-3-Clause"] = License{
|
||||
Identifier: "BSD-3-Clause",
|
||||
Name: `BSD 3-clause "New" or "Revised" License`,
|
||||
PossibleMatches: []string{"BSD-3-Clause", "bsd", "newbsd", "3 clause bsd"},
|
||||
Header: `
|
||||
All rights reserved.
|
||||
|
||||
|
@ -372,9 +377,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
`,
|
||||
}
|
||||
|
||||
Licenses["freebsd"] = License{
|
||||
Name: "Simplified BSD License",
|
||||
PossibleMatches: []string{"freebsd", "simpbsd", "simple bsd", "2 clause bsd"},
|
||||
Licenses["BSD-2-Clause"] = License{
|
||||
Identifier: "BSD-2-Clause",
|
||||
Name: `BSD 2-clause "Simplified" License`,
|
||||
PossibleMatches: []string{"BSD-2-Clause", "freebsd", "simpbsd", "simple bsd", "2 clause bsd"},
|
||||
Header: `
|
||||
All rights reserved.
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue