Skip to content

Commit

Permalink
Adjustments per PR review feedback from @BoGeM
Browse files Browse the repository at this point in the history
  • Loading branch information
bruceadowns authored and n10v committed Aug 1, 2019
1 parent d851963 commit 993cc53
Show file tree
Hide file tree
Showing 5 changed files with 1 addition and 14 deletions.
1 change: 0 additions & 1 deletion args.go
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
3 changes: 0 additions & 3 deletions cobra/cmd/project.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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 {
Expand Down
6 changes: 1 addition & 5 deletions cobra/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
3 changes: 0 additions & 3 deletions cobra/tpl/main.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package tpl

// MainTemplate defines main template string
func MainTemplate() []byte {
return []byte(`/*
{{ .Copyright }}
Expand All @@ -16,7 +15,6 @@ func main() {
`)
}

// RootTemplate defines root template string
func RootTemplate() []byte {
return []byte(`/*
{{ .Copyright }}
Expand Down Expand Up @@ -110,7 +108,6 @@ func initConfig() {
`)
}

// AddCommandTemplate defines add command template string
func AddCommandTemplate() []byte {
return []byte(`/*
{{ .Project.Copyright }}
Expand Down
2 changes: 0 additions & 2 deletions command.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 993cc53

Please sign in to comment.