mirror of
https://gitee.com/johng/gf
synced 2026-06-07 02:12:11 +08:00
improve package gcmd
This commit is contained in:
@ -208,7 +208,6 @@ func newCommandFromMethod(object interface{}, method reflect.Value) (command *Co
|
||||
// Create function that has value return.
|
||||
command.FuncWithValue = func(ctx context.Context, parser *Parser) (out interface{}, err error) {
|
||||
ctx = context.WithValue(ctx, CtxKeyParser, parser)
|
||||
ctx = context.WithValue(ctx, CtxKeyCommand, command)
|
||||
|
||||
defer func() {
|
||||
if exception := recover(); exception != nil {
|
||||
|
||||
@ -56,6 +56,8 @@ func (c *Command) RunWithValue(ctx context.Context) (value interface{}, err erro
|
||||
}
|
||||
|
||||
func (c *Command) doRun(ctx context.Context, parser *Parser) (value interface{}, err error) {
|
||||
ctx = context.WithValue(ctx, CtxKeyCommand, c)
|
||||
|
||||
// Check built-in help command.
|
||||
if parser.ContainsOpt(helpOptionName) || parser.ContainsOpt(helpOptionNameShort) {
|
||||
if c.HelpFunc != nil {
|
||||
|
||||
Reference in New Issue
Block a user