mirror of
https://github.com/spf13/cobra
synced 2024-11-24 22:57:12 +00:00
parse local flags
This commit is contained in:
parent
8bff6aff17
commit
55ff048a8d
1 changed files with 8 additions and 0 deletions
|
@ -1782,12 +1782,20 @@ func (c *Command) ParseFlags(args []string) error {
|
|||
// do it here after merging all flags and just before parse
|
||||
c.Flags().ParseErrorsWhitelist = flag.ParseErrorsWhitelist(c.FParseErrWhitelist)
|
||||
|
||||
// parse Flags
|
||||
err := c.Flags().Parse(args)
|
||||
// Print warnings if they occurred (e.g. deprecated flag messages).
|
||||
if c.flagErrorBuf.Len()-beforeErrorBufLen > 0 && err == nil {
|
||||
c.Print(c.flagErrorBuf.String())
|
||||
}
|
||||
|
||||
// parse Local Flags
|
||||
err = c.LocalFlags().Parse(args)
|
||||
// Print warnings if they occurred (e.g. deprecated flag messages).
|
||||
if c.flagErrorBuf.Len()-beforeErrorBufLen > 0 && err == nil {
|
||||
c.Print(c.flagErrorBuf.String())
|
||||
}
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue