Adjustments per PR review feedback from @bogem

This commit is contained in:
Bruce Downs 2019-08-01 09:47:14 -07:00 committed by Albert Nigmatzianov
parent d85196337c
commit 993cc5372a
5 changed files with 1 additions and 14 deletions

View file

@ -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:

View file

@ -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 {

View file

@ -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()
}

View file

@ -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 }}

View file

@ -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