From 7c973a26c7bd6ecd8d86bb435d93ff98df2710fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Mart=C3=AD?= Date: Tue, 1 Oct 2024 16:55:09 +0200 Subject: [PATCH] cmd/xurls: reject unexpected -fix string values While here, tweak the help text and run -fix itself on the README. --- README.md | 4 ++-- cmd/xurls/main.go | 5 ++++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 51560f3..298c3e0 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/cmd/xurls/main.go b/cmd/xurls/main.go index 201aaa7..3a56281 100644 --- a/cmd/xurls/main.go +++ b/cmd/xurls/main.go @@ -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. @@ -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 {