diff --git a/main.go b/main.go index a1ff8cd..69313e1 100644 --- a/main.go +++ b/main.go @@ -4,6 +4,7 @@ package main import ( "flag" "fmt" + "local/logger" "time" "github.com/eiannone/keyboard" @@ -64,7 +65,7 @@ func main() { paused := false delim := ':' - fmt.Println("Quit with 'q', Pause with 'p', Reset with 'r'") + logger.Log("Quit with 'q', Pause with 'p', Reset with 'r'") go func() { last := time.Now() @@ -86,7 +87,7 @@ func main() { monitor.Stop() } case <-stop: - fmt.Println("") + logger.Log("") confirm <- true return } @@ -122,7 +123,7 @@ func main() { notified = false printTime(&cur, base, &delim, invert, repeat, eta) case 'z': - fmt.Printf("\n") + logger.Log("\n") printTime(&cur, base, &delim, invert, repeat, eta) } } @@ -157,20 +158,22 @@ func printTime(pRemains *time.Duration, target time.Duration, delim *rune, rever } at := fmt.Sprintf("%2d%c%02d%c%02d ", hrs, byte(*delim), min, byte(*delim), seconds) rem := fmt.Sprintf("%2d%c%02d%c%02d ", rHrs, tdelim, rMin, tdelim, rSec) - rem = fmt.Sprintf("Remaining: %s \tAt: %s ", rem, at) + rem = fmt.Sprintf("%s \tAt: %s ", rem, at) if eta { rem = fmt.Sprintf("%s \tETA: %s", rem, time.Unix(0, (time.Now().UnixNano()+target.Nanoseconds()-pRemains.Nanoseconds())).Format("3:04")) } final = rem } else { rem := fmt.Sprintf("%2d%c%02d%c%02d ", hrs, byte(*delim), min, byte(*delim), seconds) - final = fmt.Sprintf("Remaining: %s ", rem) - final = fmt.Sprintf("%s \tETA: %s", final, time.Unix(0, time.Now().UnixNano()+pRemains.Nanoseconds()).Format("3:04")) + final = fmt.Sprintf("%s ", rem) + if eta { + final = fmt.Sprintf("%s \tETA: %s", final, time.Unix(0, time.Now().UnixNano()+pRemains.Nanoseconds()).Format("3:04")) + } if remains < 0 { go alertTime(pRemains, target, reverse, repeat) } } - fmt.Printf("\r%s", final) + logger.Log("\r%s", final) } func alertTime(pRemains *time.Duration, target time.Duration, reverse, repeat bool) {