diff --git a/README.md b/README.md index 45655dc..0c5fb22 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ Usage of wrun: -http-timeout duration HTTP client timeout (default 5m0s) -url value - [/=]URL (at least one required to match) + [/=]URL (at least one required) -use-pre-commit-cache Use pre-commit's cache dir diff --git a/wrun.go b/wrun.go index 635f46b..4b71262 100644 --- a/wrun.go +++ b/wrun.go @@ -135,7 +135,7 @@ type config struct { func parseFlags(set *flag.FlagSet, args []string) (config, error) { cfg := config{} cfg.urlMatches = make([]urlMatch, 0, len(args)/2+3) - set.Func("url", "[/=]URL (at least one required to match)", func(s string) error { + set.Func("url", "[/=]URL (at least one required)", func(s string) error { pattern, ur, found := strings.Cut(s, "=") if found { if strings.Contains(pattern, "://") { @@ -176,6 +176,12 @@ func parseFlags(set *flag.FlagSet, args []string) (config, error) { if err := set.Parse(args); err != nil { return config{}, err } + if len(cfg.urlMatches) == 0 { + err := errors.New("flag must occur at least once: -url") + _, _ = fmt.Fprintln(set.Output(), err) + set.Usage() + return config{}, err + } return cfg, nil }