Add RunAsSubcommand to keep API unchanged
This commit is contained in:
parent
4a109bc0ce
commit
00afca42c8
6
app.go
6
app.go
@ -305,6 +305,12 @@ 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
|
||||
// No one should really use this. Always use a.Run to execute app
|
||||
func (a *App) RunAsSubcommand(ctx *Context) (err error) {
|
||||
return a.RunContext(ctx.Context, ctx.Args().Slice())
|
||||
}
|
||||
|
||||
func (a *App) suggestFlagFromError(err error, command string) (string, error) {
|
||||
flag, parseErr := flagFromError(err)
|
||||
if parseErr != nil {
|
||||
|
@ -1050,7 +1050,6 @@ func newContextFromStringSlice(ss []string) *Context {
|
||||
return &Context{flagSet: set}
|
||||
}
|
||||
|
||||
/*
|
||||
func TestHideHelpCommand_RunAsSubcommand(t *testing.T) {
|
||||
app := &App{
|
||||
HideHelpCommand: true,
|
||||
@ -1097,7 +1096,6 @@ func TestHideHelpCommand_RunAsSubcommand_False(t *testing.T) {
|
||||
t.Errorf("Run returned unexpected error: %v", err)
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
func TestHideHelpCommand_WithSubcommands(t *testing.T) {
|
||||
app := &App{
|
||||
|
Loading…
Reference in New Issue
Block a user