From 24d27437208170463abb81819f4d0b2f45544d0b Mon Sep 17 00:00:00 2001 From: Anthony Wang Date: Mon, 28 Mar 2022 11:51:19 -0500 Subject: Verbose logging --- sd.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/sd.go b/sd.go index d1a6756..fbbd8b9 100644 --- a/sd.go +++ b/sd.go @@ -11,6 +11,7 @@ import ( _ "modernc.org/sqlite" ) +var verbose = flag.Bool("v", false, "debug output") var file = flag.String("f", "cards", "cards file") var sum = 0 @@ -76,6 +77,11 @@ func main() { build(rows, 0, N-1, 1) rows.Close() + if *verbose { + fmt.Println(N) + fmt.Println(seg) + } + // https://stackoverflow.com/questions/14094190/function-similar-to-getchar // disable input buffering exec.Command("stty", "-F", "/dev/tty", "cbreak", "min", "1").Run() @@ -87,8 +93,10 @@ func main() { for { // Choose a random card x := rand.Intn(sum) - fmt.Println(sum) - fmt.Println(x) + if *verbose { + fmt.Println(sum) + fmt.Println(x) + } w, i := query(x, 0, N-1, 1) fmt.Println(w) fmt.Println(i) -- cgit v1.2.3-70-g09d2