mirror of
https://github.com/spf13/cobra
synced 2025-07-07 11:37:17 +00:00
use findAndParseFlag instead of ParseFlags
This commit is contained in:
parent
7a0f61e6a5
commit
d2e2d77694
1 changed files with 9 additions and 7 deletions
16
command.go
16
command.go
|
@ -726,9 +726,11 @@ func (c *Command) findAndParseFlag(args []string) (*Command, error) {
|
|||
// return c.FlagErrorFunc()(c, err)
|
||||
// }
|
||||
return innerfind(cmd, afterArgs)
|
||||
}
|
||||
} else {
|
||||
c.ParseFlags(innerArgs)
|
||||
return c, innerArgs
|
||||
}
|
||||
}
|
||||
|
||||
commandFound, a := innerfind(c, args)
|
||||
if commandFound.Args == nil {
|
||||
|
@ -870,13 +872,13 @@ func (c *Command) execute(a []string) (err error) {
|
|||
|
||||
// initialize help and version flag at the last point possible to allow for user
|
||||
// overriding
|
||||
c.InitDefaultHelpFlag()
|
||||
c.InitDefaultVersionFlag()
|
||||
// c.InitDefaultHelpFlag()
|
||||
// c.InitDefaultVersionFlag()
|
||||
|
||||
err = c.ParseFlags(a)
|
||||
if err != nil {
|
||||
return c.FlagErrorFunc()(c, err)
|
||||
}
|
||||
// err = c.ParseFlags(a)
|
||||
// if err != nil {
|
||||
// return c.FlagErrorFunc()(c, err)
|
||||
// }
|
||||
|
||||
// If help is called, regardless of other flags, return we want help.
|
||||
// Also say we need help if the command isn't runnable.
|
||||
|
|
Loading…
Add table
Reference in a new issue