mirror of
https://gitee.com/johng/gf
synced 2026-06-06 02:25:47 +08:00
add strict attribute for gcmd.Command for strict option parsing
This commit is contained in:
@ -26,6 +26,7 @@ type Command struct {
|
||||
HelpFunc Function // Custom help function
|
||||
Examples string // Usage examples.
|
||||
Additional string // Additional info about this command, which will be appended to the end of help info.
|
||||
Strict bool // Strict parsing options, which means it returns error if invalid option given.
|
||||
parent *Command // Parent command for internal usage.
|
||||
commands []Command // Sub commands of this command.
|
||||
}
|
||||
|
||||
@ -97,7 +97,7 @@ func (c *Command) reParse(ctx context.Context, parser *Parser) (*Parser, error)
|
||||
}
|
||||
supportedOptions[optionKey] = !option.Orphan
|
||||
}
|
||||
return Parse(supportedOptions)
|
||||
return Parse(supportedOptions, c.Strict)
|
||||
}
|
||||
|
||||
// searchCommand recursively searches the command according given arguments.
|
||||
|
||||
Reference in New Issue
Block a user