A few follow-up conflict resolutions

This commit is contained in:
Dan Buch 2022-05-07 14:43:15 -04:00
parent 3d67b75be7
commit 63b1a7deee
Signed by: meatballhat
GPG Key ID: A12F782281063434
4 changed files with 6 additions and 2 deletions

2
app.go
View File

@ -391,7 +391,7 @@ func (a *App) RunAsSubcommand(ctx *Context) (err error) {
}
_, _ = fmt.Fprintf(a.Writer, "%s %s\n\n", "Incorrect Usage.", err.Error())
if a.Suggest {
if suggestion, err := a.suggestFlagFromError(err, context.Command.Name); err == nil {
if suggestion, err := a.suggestFlagFromError(err, cCtx.Command.Name); err == nil {
fmt.Fprintf(a.Writer, suggestion)
}
}

View File

@ -121,7 +121,7 @@ func (c *Command) Run(ctx *Context) (err error) {
_, _ = fmt.Fprintln(cCtx.App.Writer)
if ctx.App.Suggest {
if suggestion, err := ctx.App.suggestFlagFromError(err, c.Name); err == nil {
fmt.Fprintf(context.App.Writer, suggestion)
fmt.Fprintf(cCtx.App.Writer, suggestion)
}
}
_ = ShowCommandHelp(cCtx, c.Name)

View File

@ -305,6 +305,8 @@ type App struct {
// single-character bool arguments into one
// i.e. foobar -o -v -> foobar -ov
UseShortOptionHandling bool
// Enable suggestions for commands and flags
Suggest bool
// Has unexported fields.
}

View File

@ -305,6 +305,8 @@ type App struct {
// single-character bool arguments into one
// i.e. foobar -o -v -> foobar -ov
UseShortOptionHandling bool
// Enable suggestions for commands and flags
Suggest bool
// Has unexported fields.
}