summaryrefslogtreecommitdiffstats
path: root/vendor/github.com/spf13/cobra/cobra
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/spf13/cobra/cobra')
-rw-r--r--vendor/github.com/spf13/cobra/cobra/cmd/add.go4
-rw-r--r--vendor/github.com/spf13/cobra/cobra/cmd/add_test.go15
-rw-r--r--vendor/github.com/spf13/cobra/cobra/cmd/golden_test.go4
-rw-r--r--vendor/github.com/spf13/cobra/cobra/cmd/init_test.go11
-rw-r--r--vendor/github.com/spf13/cobra/cobra/cmd/license_agpl.go3
-rw-r--r--vendor/github.com/spf13/cobra/cobra/cmd/license_apache_2.go3
-rw-r--r--vendor/github.com/spf13/cobra/cobra/cmd/license_bsd_clause_2.go3
-rw-r--r--vendor/github.com/spf13/cobra/cobra/cmd/license_bsd_clause_3.go3
-rw-r--r--vendor/github.com/spf13/cobra/cobra/cmd/license_gpl_2.go27
-rw-r--r--vendor/github.com/spf13/cobra/cobra/cmd/license_gpl_3.go3
-rw-r--r--vendor/github.com/spf13/cobra/cobra/cmd/license_lgpl.go3
-rw-r--r--vendor/github.com/spf13/cobra/cobra/cmd/license_mit.go2
-rw-r--r--vendor/github.com/spf13/cobra/cobra/cmd/licenses.go6
-rw-r--r--vendor/github.com/spf13/cobra/cobra/cmd/root.go4
-rw-r--r--vendor/github.com/spf13/cobra/cobra/cmd/testdata/main.go.golden1
-rw-r--r--vendor/github.com/spf13/cobra/cobra/cmd/testdata/root.go.golden1
-rw-r--r--vendor/github.com/spf13/cobra/cobra/cmd/testdata/test.go.golden1
17 files changed, 57 insertions, 37 deletions
diff --git a/vendor/github.com/spf13/cobra/cobra/cmd/add.go b/vendor/github.com/spf13/cobra/cobra/cmd/add.go
index 45f00bb54..993ae16f0 100644
--- a/vendor/github.com/spf13/cobra/cobra/cmd/add.go
+++ b/vendor/github.com/spf13/cobra/cobra/cmd/add.go
@@ -24,7 +24,7 @@ import (
func init() {
addCmd.Flags().StringVarP(&packageName, "package", "t", "", "target package name (e.g. github.com/spf13/hugo)")
- addCmd.Flags().StringVarP(&parentName, "parent", "p", "RootCmd", "name of parent command for this command")
+ addCmd.Flags().StringVarP(&parentName, "parent", "p", "RootCmd", "variable name of parent command for this command")
}
var packageName, parentName string
@@ -121,7 +121,7 @@ func validateCmdName(source string) string {
func createCmdFile(license License, path, cmdName string) {
template := `{{comment .copyright}}
-{{comment .license}}
+{{if .license}}{{comment .license}}{{end}}
package {{.cmdPackage}}
diff --git a/vendor/github.com/spf13/cobra/cobra/cmd/add_test.go b/vendor/github.com/spf13/cobra/cobra/cmd/add_test.go
index dacbe838a..b920e2b9d 100644
--- a/vendor/github.com/spf13/cobra/cobra/cmd/add_test.go
+++ b/vendor/github.com/spf13/cobra/cobra/cmd/add_test.go
@@ -6,6 +6,8 @@ import (
"os"
"path/filepath"
"testing"
+
+ "github.com/spf13/viper"
)
// TestGoldenAddCmd initializes the project "github.com/spf13/testproject"
@@ -16,10 +18,17 @@ import (
func TestGoldenAddCmd(t *testing.T) {
projectName := "github.com/spf13/testproject"
project := NewProject(projectName)
+ defer os.RemoveAll(project.AbsPath())
- // Initialize the project at first.
+ viper.Set("author", "NAME HERE <EMAIL ADDRESS>")
+ viper.Set("license", "apache")
+ viper.Set("year", 2017)
+ defer viper.Set("author", nil)
+ defer viper.Set("license", nil)
+ defer viper.Set("year", nil)
+
+ // Initialize the project first.
initializeProject(project)
- defer os.RemoveAll(project.AbsPath())
// Then add the "test" command.
cmdName := "test"
@@ -48,7 +57,7 @@ func TestGoldenAddCmd(t *testing.T) {
goldenPath := filepath.Join("testdata", filepath.Base(path)+".golden")
switch relPath {
- // Know directories.
+ // Known directories.
case ".":
return nil
// Known files.
diff --git a/vendor/github.com/spf13/cobra/cobra/cmd/golden_test.go b/vendor/github.com/spf13/cobra/cobra/cmd/golden_test.go
index 0ac7e8935..59a5a1c9f 100644
--- a/vendor/github.com/spf13/cobra/cobra/cmd/golden_test.go
+++ b/vendor/github.com/spf13/cobra/cobra/cmd/golden_test.go
@@ -39,11 +39,11 @@ func compareFiles(pathA, pathB string) error {
// Don't execute diff if it can't be found.
return nil
}
- diffCmd := exec.Command(diffPath, pathA, pathB)
+ diffCmd := exec.Command(diffPath, "-u", pathA, pathB)
diffCmd.Stdout = output
diffCmd.Stderr = output
- output.WriteString("$ diff " + pathA + " " + pathB + "\n")
+ output.WriteString("$ diff -u " + pathA + " " + pathB + "\n")
if err := diffCmd.Run(); err != nil {
output.WriteString("\n" + err.Error())
}
diff --git a/vendor/github.com/spf13/cobra/cobra/cmd/init_test.go b/vendor/github.com/spf13/cobra/cobra/cmd/init_test.go
index 9a918b9b4..40eb4038e 100644
--- a/vendor/github.com/spf13/cobra/cobra/cmd/init_test.go
+++ b/vendor/github.com/spf13/cobra/cobra/cmd/init_test.go
@@ -6,6 +6,8 @@ import (
"os"
"path/filepath"
"testing"
+
+ "github.com/spf13/viper"
)
// TestGoldenInitCmd initializes the project "github.com/spf13/testproject"
@@ -17,6 +19,13 @@ func TestGoldenInitCmd(t *testing.T) {
project := NewProject(projectName)
defer os.RemoveAll(project.AbsPath())
+ viper.Set("author", "NAME HERE <EMAIL ADDRESS>")
+ viper.Set("license", "apache")
+ viper.Set("year", 2017)
+ defer viper.Set("author", nil)
+ defer viper.Set("license", nil)
+ defer viper.Set("year", nil)
+
os.Args = []string{"cobra", "init", projectName}
if err := rootCmd.Execute(); err != nil {
t.Fatal("Error by execution:", err)
@@ -44,7 +53,7 @@ func TestGoldenInitCmd(t *testing.T) {
goldenPath := filepath.Join("testdata", filepath.Base(path)+".golden")
switch relPath {
- // Know directories.
+ // Known directories.
case ".", "cmd":
return nil
// Known files.
diff --git a/vendor/github.com/spf13/cobra/cobra/cmd/license_agpl.go b/vendor/github.com/spf13/cobra/cobra/cmd/license_agpl.go
index 4ea036ede..bc22e9732 100644
--- a/vendor/github.com/spf13/cobra/cobra/cmd/license_agpl.go
+++ b/vendor/github.com/spf13/cobra/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/vendor/github.com/spf13/cobra/cobra/cmd/license_apache_2.go b/vendor/github.com/spf13/cobra/cobra/cmd/license_apache_2.go
index 3f330867d..38393d541 100644
--- a/vendor/github.com/spf13/cobra/cobra/cmd/license_apache_2.go
+++ b/vendor/github.com/spf13/cobra/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/vendor/github.com/spf13/cobra/cobra/cmd/license_bsd_clause_2.go b/vendor/github.com/spf13/cobra/cobra/cmd/license_bsd_clause_2.go
index f2982dab3..4a847e04a 100644
--- a/vendor/github.com/spf13/cobra/cobra/cmd/license_bsd_clause_2.go
+++ b/vendor/github.com/spf13/cobra/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/vendor/github.com/spf13/cobra/cobra/cmd/license_bsd_clause_3.go b/vendor/github.com/spf13/cobra/cobra/cmd/license_bsd_clause_3.go
index 39c9571f2..c7476b31f 100644
--- a/vendor/github.com/spf13/cobra/cobra/cmd/license_bsd_clause_3.go
+++ b/vendor/github.com/spf13/cobra/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/vendor/github.com/spf13/cobra/cobra/cmd/license_gpl_2.go b/vendor/github.com/spf13/cobra/cobra/cmd/license_gpl_2.go
index 054b470f1..03e05b3a7 100644
--- a/vendor/github.com/spf13/cobra/cobra/cmd/license_gpl_2.go
+++ b/vendor/github.com/spf13/cobra/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}}
-
- 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.
-
- 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/>.`,
+ 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 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 <http://www.gnu.org/licenses/>.`,
Text: ` GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
diff --git a/vendor/github.com/spf13/cobra/cobra/cmd/license_gpl_3.go b/vendor/github.com/spf13/cobra/cobra/cmd/license_gpl_3.go
index d1ef656a7..ce07679c7 100644
--- a/vendor/github.com/spf13/cobra/cobra/cmd/license_gpl_3.go
+++ b/vendor/github.com/spf13/cobra/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/vendor/github.com/spf13/cobra/cobra/cmd/license_lgpl.go b/vendor/github.com/spf13/cobra/cobra/cmd/license_lgpl.go
index 75fd043b8..0f8b96cad 100644
--- a/vendor/github.com/spf13/cobra/cobra/cmd/license_lgpl.go
+++ b/vendor/github.com/spf13/cobra/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/vendor/github.com/spf13/cobra/cobra/cmd/license_mit.go b/vendor/github.com/spf13/cobra/cobra/cmd/license_mit.go
index 4ff5a4cdf..bd2d0c4fa 100644
--- a/vendor/github.com/spf13/cobra/cobra/cmd/license_mit.go
+++ b/vendor/github.com/spf13/cobra/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
diff --git a/vendor/github.com/spf13/cobra/cobra/cmd/licenses.go b/vendor/github.com/spf13/cobra/cobra/cmd/licenses.go
index d73e6fb35..cf2a6b7af 100644
--- a/vendor/github.com/spf13/cobra/cobra/cmd/licenses.go
+++ b/vendor/github.com/spf13/cobra/cobra/cmd/licenses.go
@@ -77,7 +77,11 @@ func getLicense() License {
func copyrightLine() string {
author := viper.GetString("author")
- year := time.Now().Format("2006")
+
+ year := viper.GetString("year") // For tests.
+ if year == "" {
+ year = time.Now().Format("2006")
+ }
return "Copyright © " + year + " " + author
}
diff --git a/vendor/github.com/spf13/cobra/cobra/cmd/root.go b/vendor/github.com/spf13/cobra/cobra/cmd/root.go
index 1c5e69078..19568f980 100644
--- a/vendor/github.com/spf13/cobra/cobra/cmd/root.go
+++ b/vendor/github.com/spf13/cobra/cobra/cmd/root.go
@@ -40,7 +40,7 @@ func Execute() {
}
func init() {
- initViper()
+ cobra.OnInitialize(initConfig)
rootCmd.PersistentFlags().StringVar(&cfgFile, "config", "", "config file (default is $HOME/.cobra.yaml)")
rootCmd.PersistentFlags().StringP("author", "a", "YOUR NAME", "author name for copyright attribution")
@@ -55,7 +55,7 @@ func init() {
rootCmd.AddCommand(initCmd)
}
-func initViper() {
+func initConfig() {
if cfgFile != "" {
// Use config file from the flag.
viper.SetConfigFile(cfgFile)
diff --git a/vendor/github.com/spf13/cobra/cobra/cmd/testdata/main.go.golden b/vendor/github.com/spf13/cobra/cobra/cmd/testdata/main.go.golden
index 69ecbd48e..cdbe38d70 100644
--- a/vendor/github.com/spf13/cobra/cobra/cmd/testdata/main.go.golden
+++ b/vendor/github.com/spf13/cobra/cobra/cmd/testdata/main.go.golden
@@ -1,4 +1,5 @@
// Copyright © 2017 NAME HERE <EMAIL ADDRESS>
+//
// 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/vendor/github.com/spf13/cobra/cobra/cmd/testdata/root.go.golden b/vendor/github.com/spf13/cobra/cobra/cmd/testdata/root.go.golden
index ecc876012..8eeeae89e 100644
--- a/vendor/github.com/spf13/cobra/cobra/cmd/testdata/root.go.golden
+++ b/vendor/github.com/spf13/cobra/cobra/cmd/testdata/root.go.golden
@@ -1,4 +1,5 @@
// Copyright © 2017 NAME HERE <EMAIL ADDRESS>
+//
// 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/vendor/github.com/spf13/cobra/cobra/cmd/testdata/test.go.golden b/vendor/github.com/spf13/cobra/cobra/cmd/testdata/test.go.golden
index c8319d1dd..584056802 100644
--- a/vendor/github.com/spf13/cobra/cobra/cmd/testdata/test.go.golden
+++ b/vendor/github.com/spf13/cobra/cobra/cmd/testdata/test.go.golden
@@ -1,4 +1,5 @@
// Copyright © 2017 NAME HERE <EMAIL ADDRESS>
+//
// 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