Merge pull request #85 from eparis/more-simplification
More simplification
This commit is contained in:
commit
7c7837e882
18
command.go
18
command.go
@ -432,7 +432,7 @@ func (c *Command) execute(a []string) (err error) {
|
||||
c.Usage()
|
||||
r.SetOutput(out)
|
||||
return err
|
||||
} else {
|
||||
}
|
||||
// If help is called, regardless of other flags, we print that.
|
||||
// Print help also if c.Run is nil.
|
||||
if c.helpFlagVal || !c.Runnable() {
|
||||
@ -444,7 +444,6 @@ func (c *Command) execute(a []string) (err error) {
|
||||
argWoFlags := c.Flags().Args()
|
||||
c.Run(c, argWoFlags)
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
func (c *Command) preRun() {
|
||||
@ -495,21 +494,10 @@ func (c *Command) Execute() (err error) {
|
||||
args = c.args
|
||||
}
|
||||
|
||||
if len(args) == 0 {
|
||||
// Only the executable is called and the root is runnable, run it
|
||||
if c.Runnable() {
|
||||
err = c.execute([]string(nil))
|
||||
} else {
|
||||
c.Help()
|
||||
}
|
||||
} else {
|
||||
cmd, flags, e := c.Find(args)
|
||||
if e != nil {
|
||||
err = e
|
||||
} else {
|
||||
cmd, flags, err := c.Find(args)
|
||||
if err == nil {
|
||||
err = cmd.execute(flags)
|
||||
}
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
if err == flag.ErrHelp {
|
||||
|
Loading…
Reference in New Issue
Block a user