Better help text

master
Aaron Johnon 1 year ago
parent fc25a7cee0
commit 1a6944753f

@ -33,6 +33,20 @@ func applyReverseShift(value, shift int) int {
func main() { func main() {
// Define command-line flags // Define command-line flags
shift := flag.Int("s", 0, "Shift amount for the cipher") 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() flag.Parse()
// Read all input from stdin // Read all input from stdin

@ -80,9 +80,23 @@ func formatOutput(encoded []int, groupSize int, lineSize int) string {
func main() { func main() {
// Define command-line flags // Define command-line flags
shift := flag.Int("s", 0, "Shift amount for the cipher") 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") 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 or characters if no group size is specified") 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() flag.Parse()
// Read input from stdin // Read input from stdin

Loading…
Cancel
Save