Skip to content
Myr

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

5 files+1 added−14 removed

modified:cobra/cmd/project.go-3 removed
17 unmodified lines
18 Viper bool19 AppName string20}2122// Command structure22type Command struct {23 CmdName string24 CmdParent string25 *Project26}2729// Create project receiver28func (p *Project) Create() error {29 // check if AbsolutePath exists30 if _, err := os.Stat(p.AbsolutePath); os.IsNotExist(err) {31 // create directory
47 unmodified lines
79 licenseTemplate := template.Must(template.New("license").Parse(p.Legal.Text))80 return licenseTemplate.Execute(licenseFile, data)81}8285// Create command receiver83func (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 err
10 unmodified lines
modified:cobra/tpl/main.go-3 removed
1package tpl23// MainTemplate defines main template string3func MainTemplate() []byte {4 return []byte(`/*5{{ .Copyright }}6{{ if .Legal.Header }}{{ .Legal.Header }}{{ end }}
7 unmodified lines
14}15`)16}1719// RootTemplate defines root template string18func RootTemplate() []byte {19 return []byte(`/*20{{ .Copyright }}21{{ if .Legal.Header }}{{ .Legal.Header }}{{ end }}
85 unmodified lines
107{{ end }}108`)109}110113// AddCommandTemplate defines add command template string111func AddCommandTemplate() []byte {112 return []byte(`/*113{{ .Project.Copyright }}114{{ if .Legal.Header }}{{ .Legal.Header }}{{ end }}
39 unmodified lines
modified:cobra/main.go+1 added-5 removed
18 unmodified lines
19 "github.com/spf13/cobra/cobra/cmd"20)2122func main() {23 if err := runMain(); err != nil {23 if err := cmd.Execute(); err != nil {24 os.Exit(1)25 }26}2728func runMain() error {29 return cmd.Execute()30}
modified:args.go-1 removed
2 unmodified lines
3import (4 "fmt"5)67// PositionalArgs defines positional arguments callback7type PositionalArgs func(cmd *Command, args []string) error89// Legacy arg validation has the following behaviour:10// - root commands with no subcommands can take arbitrary arguments
91 unmodified lines
modified:command.go-2 removed
26 unmodified lines
2728 flag "github.com/spf13/pflag"29)3031// ErrSubCommandRequired defines subcommand error31var ErrSubCommandRequired = errors.New("subcommand is required")3233// FParseErrWhitelist configures Flag parse errors to be ignored34type FParseErrWhitelist flag.ParseErrorsWhitelist
910 unmodified lines
945 }946 return cmd, err947}948950// ValidateArgs validates arguments949func (c *Command) ValidateArgs(args []string) error {950 if c.Args == nil {951 return nil952 }
653 unmodified lines