Made sleeper configurable

drew/sql-it
Drew Bednar 7 months ago
parent aa7df72415
commit 6e434e487d

Binary file not shown.

@ -1,6 +1,7 @@
package main package main
import ( import (
"flag"
"fmt" "fmt"
"io" "io"
"os" "os"
@ -40,6 +41,10 @@ func Countdown(out io.Writer, sleeper Sleeper, count int) {
} }
func main() { func main() {
sleeper := &ConfigurableSleeper{1 * time.Second, time.Sleep} count := flag.Int("count", 3, "Countdown start number")
Countdown(os.Stdout, sleeper, 3) seconds := flag.Float64("seconds", 1, "Number of sleep seconds between count calls")
flag.Parse()
sleeper := &ConfigurableSleeper{time.Duration(*seconds * float64(time.Second)), time.Sleep}
Countdown(os.Stdout, sleeper, *count)
} }

Loading…
Cancel
Save