mirror of
https://github.com/spf13/cobra
synced 2025-05-05 21:07:24 +00:00
Unify generation of data for template expansion using ProjectToMap()
This commit is contained in:
parent
15eff95ef4
commit
e1be966340
1 changed files with 2 additions and 9 deletions
|
@ -16,7 +16,6 @@ package cmd
|
|||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"path"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
|
@ -117,10 +116,7 @@ func main() {
|
|||
cmd.Execute()
|
||||
}
|
||||
`
|
||||
data := make(map[string]interface{})
|
||||
data["copyright"] = copyrightLine()
|
||||
data["license"] = project.License().Header
|
||||
data["importpath"] = path.Join(project.Name(), filepath.Base(project.CmdPath()))
|
||||
data := project.ProjectToMap()
|
||||
|
||||
mainScript, err := executeTemplate(mainTemplate, data)
|
||||
if err != nil {
|
||||
|
@ -215,11 +211,8 @@ func initConfig() {
|
|||
}{{ end }}
|
||||
`
|
||||
|
||||
data := make(map[string]interface{})
|
||||
data["copyright"] = copyrightLine()
|
||||
data := project.ProjectToMap()
|
||||
data["viper"] = viper.GetBool("useViper")
|
||||
data["license"] = project.License().Header
|
||||
data["appName"] = path.Base(project.Name())
|
||||
|
||||
rootCmdScript, err := executeTemplate(template, data)
|
||||
if err != nil {
|
||||
|
|
Loading…
Add table
Reference in a new issue