fix: improve usage message and error handling for input file requirement

This commit is contained in:
Jason Cameron
2025-06-14 10:07:53 -04:00
parent 5730801928
commit ddcde1f2a3

View File

@@ -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