aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sd.go12
1 files 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)