Skip to content

Commit

Permalink
Fix:(issue_1610). Keep RunAsSubcommand behaviour as before
Browse files Browse the repository at this point in the history
  • Loading branch information
dearchap committed May 21, 2023
1 parent c0cc5c2 commit bc224e9
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion app.go
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,15 @@ func (a *App) RunContext(ctx context.Context, arguments []string) (err error) {
//
// Deprecated: use App.Run or App.RunContext
func (a *App) RunAsSubcommand(ctx *Context) (err error) {
return a.RunContext(ctx.Context, ctx.Args().Slice())
a.Setup()

cCtx := NewContext(a, nil, ctx)
cCtx.shellComplete = ctx.shellComplete

a.rootCommand = a.newRootCommand()
cCtx.Command = a.rootCommand

return a.rootCommand.Run(cCtx, ctx.Args().Slice()...)
}

func (a *App) suggestFlagFromError(err error, command string) (string, error) {
Expand Down

0 comments on commit bc224e9

Please sign in to comment.