From 993cc5372a05240dfd59e3ba952748b36b2cd117 Mon Sep 17 00:00:00 2001 From: Bruce Downs Date: Thu, 1 Aug 2019 09:47:14 -0700 Subject: [PATCH] Adjustments per PR review feedback from @bogem --- args.go | 1 - cobra/cmd/project.go | 3 --- cobra/main.go | 6 +----- cobra/tpl/main.go | 3 --- command.go | 2 -- 5 files changed, 1 insertion(+), 14 deletions(-) diff --git a/args.go b/args.go index e5a34c167..c4d820b85 100644 --- a/args.go +++ b/args.go @@ -4,7 +4,6 @@ import ( "fmt" ) -// PositionalArgs defines positional arguments callback type PositionalArgs func(cmd *Command, args []string) error // Legacy arg validation has the following behaviour: diff --git a/cobra/cmd/project.go b/cobra/cmd/project.go index a71cae317..a53893ccd 100644 --- a/cobra/cmd/project.go +++ b/cobra/cmd/project.go @@ -19,14 +19,12 @@ type Project struct { AppName string } -// Command structure type Command struct { CmdName string CmdParent string *Project } -// Create project receiver func (p *Project) Create() error { // check if AbsolutePath exists if _, err := os.Stat(p.AbsolutePath); os.IsNotExist(err) { @@ -82,7 +80,6 @@ func (p *Project) createLicenseFile() error { return licenseTemplate.Execute(licenseFile, data) } -// Create command receiver func (c *Command) Create() error { cmdFile, err := os.Create(fmt.Sprintf("%s/cmd/%s.go", c.AbsolutePath, c.CmdName)) if err != nil { diff --git a/cobra/main.go b/cobra/main.go index 8add69a88..eeaf9824e 100644 --- a/cobra/main.go +++ b/cobra/main.go @@ -20,11 +20,7 @@ import ( ) func main() { - if err := runMain(); err != nil { + if err := cmd.Execute(); err != nil { os.Exit(1) } } - -func runMain() error { - return cmd.Execute() -} diff --git a/cobra/tpl/main.go b/cobra/tpl/main.go index f6fe8977e..5e5a0fae2 100644 --- a/cobra/tpl/main.go +++ b/cobra/tpl/main.go @@ -1,6 +1,5 @@ package tpl -// MainTemplate defines main template string func MainTemplate() []byte { return []byte(`/* {{ .Copyright }} @@ -16,7 +15,6 @@ func main() { `) } -// RootTemplate defines root template string func RootTemplate() []byte { return []byte(`/* {{ .Copyright }} @@ -110,7 +108,6 @@ func initConfig() { `) } -// AddCommandTemplate defines add command template string func AddCommandTemplate() []byte { return []byte(`/* {{ .Project.Copyright }} diff --git a/command.go b/command.go index ca6dc1395..42e500de5 100644 --- a/command.go +++ b/command.go @@ -28,7 +28,6 @@ import ( flag "github.com/spf13/pflag" ) -// ErrSubCommandRequired defines subcommand error var ErrSubCommandRequired = errors.New("subcommand is required") // FParseErrWhitelist configures Flag parse errors to be ignored @@ -947,7 +946,6 @@ func (c *Command) ExecuteC() (cmd *Command, err error) { return cmd, err } -// ValidateArgs validates arguments func (c *Command) ValidateArgs(args []string) error { if c.Args == nil { return nil