Adjustments per PR review feedback from @bogem
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by Bruce Downs · committed by Albert Nigmatzianov · parent d851963 · Browse files · 5 files·+1 added−14 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
5 files+1 added−14 removed
- other:+1 added−14 removed
Provenance
- Commit
993cc53- Tree
116459c- Author
Bruce Downs <bruce.downs@autodesk.com>- Committer
Albert Nigmatzianov <albertnigma@gmail.com>- Parent
d851963
5 files changed+1 added−14 removed
modified:cobra/cmd/project.go-3 removed
17 unmodified lines18 Viper bool19 AppName string20 }21 22-// Command structure22 type Command struct {23 CmdName string24 CmdParent string25 *Project26 }27 29-// Create project receiver28 func (p *Project) Create() error {29 // check if AbsolutePath exists30 if _, err := os.Stat(p.AbsolutePath); os.IsNotExist(err) {31 // create directory47 unmodified lines79 licenseTemplate := template.Must(template.New("license").Parse(p.Legal.Text))80 return licenseTemplate.Execute(licenseFile, data)81 }82 85-// Create command receiver83 func (c *Command) Create() error {84 cmdFile, err := os.Create(fmt.Sprintf("%s/cmd/%s.go", c.AbsolutePath, c.CmdName))85 if err != nil {86 return err10 unmodified linesmodified:cobra/tpl/main.go-3 removed
1 package tpl2 3-// MainTemplate defines main template string3 func MainTemplate() []byte {4 return []byte(`/*5 {{ .Copyright }}6 {{ if .Legal.Header }}{{ .Legal.Header }}{{ end }}7 unmodified lines14 }15 `)16 }17 19-// RootTemplate defines root template string18 func RootTemplate() []byte {19 return []byte(`/*20 {{ .Copyright }}21 {{ if .Legal.Header }}{{ .Legal.Header }}{{ end }}85 unmodified lines107 {{ end }}108 `)109 }110 113-// AddCommandTemplate defines add command template string111 func AddCommandTemplate() []byte {112 return []byte(`/*113 {{ .Project.Copyright }}114 {{ if .Legal.Header }}{{ .Legal.Header }}{{ end }}39 unmodified linesmodified:cobra/main.go+1 added-5 removed
18 unmodified lines19 "github.com/spf13/cobra/cobra/cmd"20 )21 22 func main() {23- if err := runMain(); err != nil {23+ if err := cmd.Execute(); err != nil {24 os.Exit(1)25 }26 }27-28-func runMain() error {29- return cmd.Execute()30-}modified:args.go-1 removed
2 unmodified lines3 import (4 "fmt"5 )6 7-// PositionalArgs defines positional arguments callback7 type PositionalArgs func(cmd *Command, args []string) error8 9 // Legacy arg validation has the following behaviour:10 // - root commands with no subcommands can take arbitrary arguments91 unmodified linesmodified:command.go-2 removed
26 unmodified lines27 28 flag "github.com/spf13/pflag"29 )30 31-// ErrSubCommandRequired defines subcommand error31 var ErrSubCommandRequired = errors.New("subcommand is required")32 33 // FParseErrWhitelist configures Flag parse errors to be ignored34 type FParseErrWhitelist flag.ParseErrorsWhitelist910 unmodified lines945 }946 return cmd, err947 }948 950-// ValidateArgs validates arguments949 func (c *Command) ValidateArgs(args []string) error {950 if c.Args == nil {951 return nil952 }653 unmodified lines