Skip to content

Commit

Permalink
fix: short flag not found error
Browse files Browse the repository at this point in the history
Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>
  • Loading branch information
caarlos0 committed Jan 16, 2025
1 parent 42cd69a commit c4461d4
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions flag.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,13 @@ func newFlagParseError(err error) flagParseError {
case strings.HasPrefix(s, "unknown flag:"):
reason = "Flag %s is missing."
flag = strings.TrimPrefix(s, "unknown flag: ")
case strings.HasPrefix(s, "unknown shorthand flag:"):
reason = "Short flag %s is missing."
re := regexp.MustCompile(`unknown shorthand flag: '.*' in (-\w)`)
parts := re.FindStringSubmatch(s)
if len(parts) > 1 {
flag = parts[1]
}
case strings.HasPrefix(s, "invalid argument"):
reason = "Flag %s have an invalid argument."
re := regexp.MustCompile(`invalid argument ".*" for "(.*)" flag: .*`)
Expand Down

0 comments on commit c4461d4

Please sign in to comment.