From 3aa2bf9eb574f5a7c48018883c37489063adcc2e Mon Sep 17 00:00:00 2001 From: Aaron Johnon Date: Mon, 2 Sep 2024 02:51:55 -0500 Subject: [PATCH] Better help text --- numberstation.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/numberstation.go b/numberstation.go index 58e812f..80911c6 100644 --- a/numberstation.go +++ b/numberstation.go @@ -27,6 +27,24 @@ const ( func main() { // Define and parse the -r flag repeat := flag.Bool("r", false, "Repeat each section separated by space, '-', '_', or a new line") + + flag.Usage = func() { + fmt.Fprintf(os.Stderr, "Usage: %s [options]\n", os.Args[0]) + fmt.Fprintf(os.Stderr, " %s [options] <<< \"String\"\n", os.Args[0]) + fmt.Fprintf(os.Stderr, " %s [options] < file.txt\n", os.Args[0]) + fmt.Fprintf(os.Stderr, " echo \"string\" | %s [options]\n", os.Args[0]) + fmt.Fprintf(os.Stderr, "\nDescription:\n") + fmt.Fprintf(os.Stderr, " A basic numbers station program that will read out loud the text of a provided string, one character at a time. It will\n") + fmt.Fprintf(os.Stderr, " pause on line breaks, spaces, -, and _, and will repeat each section delimited by one of these characters if -r is used.\n") + fmt.Fprintf(os.Stderr, " It also allows for an interactive mode if nothing is provided on stdin.\n") + fmt.Fprintf(os.Stderr, "\nOptions:\n") + flag.PrintDefaults() // Print the default flag help information + fmt.Fprintf(os.Stderr, "\nExamples:\n") + fmt.Fprintf(os.Stderr, " %s <<< \"22101 12102 11210 20302 22072 122\"\n", os.Args[0]) + fmt.Fprintf(os.Stderr, " %s -r < file.txt\n", os.Args[0]) + fmt.Fprintf(os.Stderr, " %s\n", os.Args[0]) + } + flag.Parse() // Create a map to store sound data for each character