Skip to content

Commit

Permalink
fix(opflags): exit gracefully if invoked with the help flag
Browse files Browse the repository at this point in the history
  • Loading branch information
tgragnato committed Nov 30, 2024
1 parent acf6878 commit ef502d6
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion opflags/parsers.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,12 @@ import (
)

func (o *OpFlags) Parse() (err error) {
_, err = flags.Parse(o)
parser := flags.NewParser(o, flags.Default)
_, err = parser.Parse()
if err != nil {
if flagsErr, ok := err.(*flags.Error); ok && flagsErr.Type == flags.ErrHelp {
os.Exit(0)
}
return err
}

Expand Down

0 comments on commit ef502d6

Please sign in to comment.