Skip to content

Commit

Permalink
fix: app help not working on input -h|--help
Browse files Browse the repository at this point in the history
  • Loading branch information
inhere committed Jul 18, 2022
1 parent f1b474e commit 0231311
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion app.go
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ func (app *App) AddAliases(name string, aliases ...string) {

// parseGlobalOpts parse global options
func (app *App) parseGlobalOpts(args []string) (ok bool) {
Logf(VerbDebug, "will begin parse global options")
Logf(VerbDebug, "will begin parse application options")

// parse global options
err := app.core.doParseGOpts(args)
Expand Down
8 changes: 6 additions & 2 deletions base.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"strings"

"github.com/gookit/color"
"github.com/gookit/goutil/cflag"
"github.com/gookit/goutil/mathutil"
"github.com/gookit/goutil/structs"
"github.com/gookit/goutil/strutil"
Expand Down Expand Up @@ -43,17 +44,20 @@ type core struct {
// })
// }

// parse global options
func (c core) doParseGOpts(args []string) (err error) {
if c.gFlags == nil { // skip on nil
return
}

// parse global options
err = c.gFlags.Parse(args)

if err != nil {
if cflag.IsFlagHelpErr(err) {
return nil
}
Logf(VerbWarn, "parse global options err: <red>%s</>", err.Error())
}

return
}

Expand Down

0 comments on commit 0231311

Please sign in to comment.