Skip to content
Myr

cmd: Fix package name when adding command

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Albert Nigmatzianov · committed by Albert Nigmatzianov · parent 4673102 · Browse files · 1 file+2 added−3 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+2 added−3 removed

  • other:+2 added−3 removed

1 file+2 added−3 removed

modified:cobra/cmd/add.go+2 added-3 removed
18 unmodified lines
19 "path/filepath"20 "unicode"2122 "github.com/spf13/cobra"23 "github.com/spf13/viper"23)2425func init() {26 addCmd.Flags().StringVarP(&parentName, "parent", "p", "RootCmd", "name of parent command for this command")
88 unmodified lines
115func createCmdFile(license License, path, cmdName string) {116 template := `{{comment .copyright}}117{{comment .license}}118120package cmd119package {{.cmdPackage}}120121import (122 "fmt"123
32 unmodified lines
156157 data := make(map[string]interface{})158 data["copyright"] = copyrightLine()159 data["license"] = license.Header161 data["viper"] = viper.GetBool("useViper")160 data["cmdPackage"] = filepath.Base(filepath.Dir(path)) // last dir of path161 data["parentName"] = parentName162 data["cmdName"] = cmdName163164 cmdScript, err := executeTemplate(template, data)
8 unmodified lines