diff --git a/nsdecode.go b/nsdecode.go index 4b6f4e0..fd6f04e 100644 --- a/nsdecode.go +++ b/nsdecode.go @@ -33,6 +33,20 @@ func applyReverseShift(value, shift int) int { func main() { // Define command-line flags shift := flag.Int("s", 0, "Shift amount for the cipher") + + 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 decrypting very basic ciphers for numbers station projects using the logic of nsencode.\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 <<< \"22101 12102 11210 20302 22072 122\"\n", os.Args[0]) + fmt.Fprintf(os.Stderr, " %s -s 16 < file.txt\n", os.Args[0]) + } + flag.Parse() // Read all input from stdin diff --git a/nsencode.go b/nsencode.go index 1d1a6d2..359b36a 100644 --- a/nsencode.go +++ b/nsencode.go @@ -80,9 +80,23 @@ func formatOutput(encoded []int, groupSize int, lineSize int) string { func main() { // Define command-line flags - shift := flag.Int("s", 0, "Shift amount for the cipher") - groupSize := flag.Int("g", 0, "Group size for output formatting") - lineSize := flag.Int("l", 0, "Line size by number of groups or characters if no group size is specified") + shift := flag.Int("s", 0, "Shift amount for the cipher -- '-s 2' will encode A as 03 instead of 01") + groupSize := flag.Int("g", 0, "Group size for output formatting -- '-g 5' will output numbers in groups of 5") + lineSize := flag.Int("l", 0, "Line size by number of groups -- '-l 4' will split to a new line after every 4th group") + + 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 4 <<< \"This is a test\"\n", os.Args[0]) + fmt.Fprintf(os.Stderr, " %s -s 16 -g 5 -l 4 < file.txt | numberstation -r\n", os.Args[0]) + } + flag.Parse() // Read input from stdin