help : errors.As : assign to the HelpError constructed at callsite

This commit is contained in:
bth 2026-01-29 11:17:52 -08:00
commit 3f5d73bf3e
6 changed files with 12 additions and 18 deletions

View file

@ -72,9 +72,8 @@ func Sort(args []string) {
opts := initOpts()
help := flags.NewHelpError(CMD, SUMMARY)
if err := flags.ParseArgs(help, args, &opts); err != nil {
var herr flags.HelpError
if errors.As(err, &herr) {
fmt.Println(herr)
if errors.As(err, &help) {
fmt.Println(help)
return
}
log.Fatalf("um %s: %s", CMD, err)