From ddcde1f2a326545d3ef2ec32e5e03f55f4f931a8 Mon Sep 17 00:00:00 2001 From: Jason Cameron Date: Sat, 14 Jun 2025 10:07:53 -0400 Subject: [PATCH] fix: improve usage message and error handling for input file requirement --- cmd/robots2policy/main.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/cmd/robots2policy/main.go b/cmd/robots2policy/main.go index 811fc156..2c3dfacd 100644 --- a/cmd/robots2policy/main.go +++ b/cmd/robots2policy/main.go @@ -45,15 +45,22 @@ type AnubisRule struct { // betteralign:ignore, we want name to be the first fie } func main() { + flag.Usage = func() { + fmt.Fprintf(os.Stderr, "Usage of %s:\n", os.Args[0]) + flag.PrintDefaults() + } + flag.Parse() if *helpFlag || flag.NFlag() == 0 { - showHelp() + flag.Usage() return } if *inputFile == "" { - log.Fatal("input file is required (use -input flag or -help for usage)") + fmt.Fprintln(os.Stderr, "Error: input file is required.") + flag.Usage() + os.Exit(2) } // Read robots.txt