mirror of
https://github.com/spf13/cobra
synced 2024-11-04 21:07:19 +00:00
cmd: Fix package name when adding command
This commit is contained in:
parent
4673102358
commit
3454e0e28e
1 changed files with 2 additions and 3 deletions
|
@ -20,7 +20,6 @@ import (
|
||||||
"unicode"
|
"unicode"
|
||||||
|
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
"github.com/spf13/viper"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
@ -117,7 +116,7 @@ func createCmdFile(license License, path, cmdName string) {
|
||||||
template := `{{comment .copyright}}
|
template := `{{comment .copyright}}
|
||||||
{{comment .license}}
|
{{comment .license}}
|
||||||
|
|
||||||
package cmd
|
package {{.cmdPackage}}
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
@ -158,7 +157,7 @@ func init() {
|
||||||
data := make(map[string]interface{})
|
data := make(map[string]interface{})
|
||||||
data["copyright"] = copyrightLine()
|
data["copyright"] = copyrightLine()
|
||||||
data["license"] = license.Header
|
data["license"] = license.Header
|
||||||
data["viper"] = viper.GetBool("useViper")
|
data["cmdPackage"] = filepath.Base(filepath.Dir(path)) // last dir of path
|
||||||
data["parentName"] = parentName
|
data["parentName"] = parentName
|
||||||
data["cmdName"] = cmdName
|
data["cmdName"] = cmdName
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue