diff options
| -rw-r--r-- | args.go | 5 | ||||
| -rw-r--r-- | radix_info.go | 14 |
2 files changed, 17 insertions, 2 deletions
@@ -16,6 +16,7 @@ type args struct { FullMap bool ExactMTCLarge bool TotativeDigits bool + DigitMapOnly bool // If true, exit the program immediately after parsing args. Exit bool } @@ -23,6 +24,8 @@ type args struct { func parseArgs() (args, error) { var a args flag.BoolVar(&a.Compact, "c", false, "Compact the output display") + flag.BoolVar(&a.DigitMapOnly, "d", false, + "Show only the digit map; incompatible with -m and -t") flag.BoolVar(&a.FullMap, "f", false, fmt.Sprintf("Show full digit map (up to %d) for every radix", maxSmallRadix)) @@ -45,6 +48,8 @@ func parseArgs() (args, error) { return args{Exit: true}, nil } else if a.Compact && a.TotativeDigits { return args{}, errors.New("You cannot use both -t and -c at the same time.") + } else if a.DigitMapOnly && (a.TotativeDigits || a.ExactMTCLarge) { + return args{}, errors.New("You cannot use both -d and -t or -m at the same time.") } else { if flag.NArg() == 1 { if radix, err := strconv.ParseUint(flag.Arg(0), 0, 0); err == nil { diff --git a/radix_info.go b/radix_info.go index f495905..befc25d 100644 --- a/radix_info.go +++ b/radix_info.go @@ -14,9 +14,19 @@ func main() { if err == nil { factorInfo := getFactorInfo(args) if args.Compact { - factorInfo.writeToCompact(os.Stdout) + if args.DigitMapOnly { + fmt.Printf("Radix %02d ", args.Radix) + writeDigitMapCompact(os.Stdout, factorInfo.DigitMap) + } else { + factorInfo.writeToCompact(os.Stdout) + } } else { - factorInfo.writeTo(os.Stdout) + if args.DigitMapOnly { + fmt.Printf("Radix %d Digit Map:\n", args.Radix) + writeDigitMap(os.Stdout, factorInfo.DigitMap) + } else { + factorInfo.writeTo(os.Stdout) + } } } else { fmt.Fprintln(os.Stderr, err) |
