Skip to content

Commit

Permalink
Merge pull request #1736 from dearchap/issue_1610
Browse files Browse the repository at this point in the history
Fix:(issue_1610). Keep RunAsSubcommand behaviour as before
  • Loading branch information
dearchap committed May 27, 2023
2 parents ad51187 + 218c1f4 commit c1bfd14
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions app.go
Original file line number Diff line number Diff line change
Expand Up @@ -332,11 +332,18 @@ func (a *App) RunContext(ctx context.Context, arguments []string) (err error) {
return a.rootCommand.Run(cCtx, arguments...)
}

// This is a stub function to keep public API unchanged from old code
//
// Deprecated: use App.Run or App.RunContext
// RunAsSubcommand is for legacy/compatibility purposes only. New code should only
// use App.RunContextMost. This function is slated to be removed in v3
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 c1bfd14

Please sign in to comment.