Skip to content

Commit

Permalink
cmd/xurls: reject unexpected -fix string values
Browse files Browse the repository at this point in the history
While here, tweak the help text and run -fix itself on the README.
  • Loading branch information
mvdan committed Oct 1, 2024
1 parent c5b6e99 commit 7c973a2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ func main() {
}
```

Since API is centered around [regexp.Regexp](https://golang.org/pkg/regexp/#Regexp),
many other methods are available, such as finding the [byte indexes](https://golang.org/pkg/regexp/#Regexp.FindAllIndex)
Since API is centered around [regexp.Regexp](https://pkg.go.dev/regexp#Regexp),
many other methods are available, such as finding the [byte indexes](https://pkg.go.dev/regexp#Regexp.FindAllIndex)
for all matches.

The regular expressions are compiled when the API is first called.
Expand Down
5 changes: 4 additions & 1 deletion cmd/xurls/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func init() {
flag.Var(&fix, "fix", "")
flag.Usage = func() {
fmt.Fprint(os.Stderr, `
Usage: xurls [-h] [files]
Usage: xurls [flags] [files]
xurls extracts urls from text using regular expressions.
If no files are given, it reads from standard input.
Expand Down Expand Up @@ -230,6 +230,9 @@ func main1() int {
case "auto", "all": // enabled via -fix=auto, -fix=all, etc
case "true": // enabled via -fix; normalize
fix = "auto"
default:
flag.Usage()
return 1
}
var re *regexp.Regexp
if *relaxed {
Expand Down

0 comments on commit 7c973a2

Please sign in to comment.