From 78c3977594456f1e24eb26b784f10a208d7d9460 Mon Sep 17 00:00:00 2001 From: Aaron Johnon Date: Wed, 28 Aug 2024 23:53:34 -0500 Subject: [PATCH] Updated help text --- nsencoder.go | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/nsencoder.go b/nsencoder.go index 2cdfdfd..692e1a6 100644 --- a/nsencoder.go +++ b/nsencoder.go @@ -13,17 +13,29 @@ import ( func main() { // Define the shift, hex, space, and grouping flags shift := flag.Int("s", 0, "Shift value for alphabet positions (can be negative)") - useHex := flag.Bool("x", false, "Encode numbers in hexadecimal") - encodeSpaces := flag.Bool("S", false, "Encode spaces as '00'") + useHex := flag.Bool("x", false, "Encode numbers in hexadecimal instead of decimal") + encodeSpaces := flag.Bool("S", false, "Encodes spaces as '00'") groupSize := flag.Int("g", 2, "Group size for output digits (minimum value of 2, default 2)") + + flag.Usage = func() { + fmt.Fprintf(os.Stderr, "Usage: %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 companion program to numberstation, intended to make easy work of making very basic ciphers for numbers station projects.\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 -s 2 -g 5 <<< \"This is a test.\"\n", os.Args[0]) + fmt.Fprintf(os.Stderr, " %s -S -s 16 -x -g 4 < file.txt | numberstation -r\n", os.Args[0]) + } + flag.Parse() // Check for invalid group size - if *groupSize == 1 { + if *groupSize < 2 { fmt.Fprintln(os.Stderr, "Error: Minimum group size is 2. Exiting.") os.Exit(1) - } else if *groupSize <= 0 { - *groupSize = 2 } // Check if input is being piped or passed as an argument