to logger
parent
13885f7ba6
commit
79efedff5a
17
main.go
17
main.go
|
|
@ -4,6 +4,7 @@ package main
|
||||||
import (
|
import (
|
||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"local/logger"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/eiannone/keyboard"
|
"github.com/eiannone/keyboard"
|
||||||
|
|
@ -64,7 +65,7 @@ func main() {
|
||||||
paused := false
|
paused := false
|
||||||
delim := ':'
|
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() {
|
go func() {
|
||||||
last := time.Now()
|
last := time.Now()
|
||||||
|
|
@ -86,7 +87,7 @@ func main() {
|
||||||
monitor.Stop()
|
monitor.Stop()
|
||||||
}
|
}
|
||||||
case <-stop:
|
case <-stop:
|
||||||
fmt.Println("")
|
logger.Log("")
|
||||||
confirm <- true
|
confirm <- true
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
@ -122,7 +123,7 @@ func main() {
|
||||||
notified = false
|
notified = false
|
||||||
printTime(&cur, base, &delim, invert, repeat, eta)
|
printTime(&cur, base, &delim, invert, repeat, eta)
|
||||||
case 'z':
|
case 'z':
|
||||||
fmt.Printf("\n")
|
logger.Log("\n")
|
||||||
printTime(&cur, base, &delim, invert, repeat, eta)
|
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)
|
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("%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 {
|
if eta {
|
||||||
rem = fmt.Sprintf("%s \tETA: %s", rem, time.Unix(0, (time.Now().UnixNano()+target.Nanoseconds()-pRemains.Nanoseconds())).Format("3:04"))
|
rem = fmt.Sprintf("%s \tETA: %s", rem, time.Unix(0, (time.Now().UnixNano()+target.Nanoseconds()-pRemains.Nanoseconds())).Format("3:04"))
|
||||||
}
|
}
|
||||||
final = rem
|
final = rem
|
||||||
} else {
|
} else {
|
||||||
rem := fmt.Sprintf("%2d%c%02d%c%02d ", hrs, byte(*delim), min, byte(*delim), seconds)
|
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 ", rem)
|
||||||
final = fmt.Sprintf("%s \tETA: %s", final, time.Unix(0, time.Now().UnixNano()+pRemains.Nanoseconds()).Format("3:04"))
|
if eta {
|
||||||
|
final = fmt.Sprintf("%s \tETA: %s", final, time.Unix(0, time.Now().UnixNano()+pRemains.Nanoseconds()).Format("3:04"))
|
||||||
|
}
|
||||||
if remains < 0 {
|
if remains < 0 {
|
||||||
go alertTime(pRemains, target, reverse, repeat)
|
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) {
|
func alertTime(pRemains *time.Duration, target time.Duration, reverse, repeat bool) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue