diff --git a/cobra/README.md b/cobra/README.md index 6054f95c..fad7c225 100644 --- a/cobra/README.md +++ b/cobra/README.md @@ -92,3 +92,6 @@ license: You can also use built-in licenses. For example, **GPLv2**, **GPLv3**, **LGPL**, **AGPL**, **MIT**, **2-Clause BSD** or **3-Clause BSD**. + +You can prevent the generation of the `// Copyright © 2015 AUTHOR ` line +at the top of the file by setting `author` to `none`. diff --git a/cobra/cmd/add.go b/cobra/cmd/add.go index fb22096a..80b59330 100644 --- a/cobra/cmd/add.go +++ b/cobra/cmd/add.go @@ -120,9 +120,9 @@ func validateCmdName(source string) string { } func createCmdFile(license License, path, cmdName string) { - template := `{{comment .copyright}} -{{if .license}}{{comment .license}}{{end}} - + template := `{{if .copyright}}{{comment .copyright}} +{{end}}{{if .license}}{{comment .license}} +{{end}} package {{.cmdPackage}} import ( diff --git a/cobra/cmd/init.go b/cobra/cmd/init.go index d65e6c8c..e2efd597 100644 --- a/cobra/cmd/init.go +++ b/cobra/cmd/init.go @@ -106,9 +106,9 @@ func createLicenseFile(license License, path string) { } func createMainFile(project *Project) { - mainTemplate := `{{ comment .copyright }} -{{if .license}}{{ comment .license }}{{end}} - + mainTemplate := `{{if .copyright}}{{comment .copyright}} +{{end}}{{if .license}}{{comment .license}} +{{end}} package main import "{{ .importpath }}" @@ -134,9 +134,9 @@ func main() { } func createRootCmdFile(project *Project) { - template := `{{comment .copyright}} -{{if .license}}{{comment .license}}{{end}} - + template := `{{if .copyright}}{{comment .copyright}} +{{end}}{{if .license}}{{comment .license}} +{{end}} package cmd import ( diff --git a/cobra/cmd/licenses.go b/cobra/cmd/licenses.go index a070134d..61b28dfa 100644 --- a/cobra/cmd/licenses.go +++ b/cobra/cmd/licenses.go @@ -77,6 +77,9 @@ func getLicense() License { func copyrightLine() string { author := viper.GetString("author") + if author == "none" { + return "" + } year := viper.GetString("year") // For tests. if year == "" {