Add interval variable

This commit is contained in:
Ivan Danyliuk 2017-12-16 12:51:18 +01:00
parent 9e8ec35160
commit 2c1b6ec3e2
No known key found for this signature in database
GPG Key ID: 97ED33CE024E1DBF
1 changed files with 6 additions and 3 deletions

View File

@ -9,7 +9,8 @@ import (
)
var (
debug = flag.Bool("noui", false, "Disable UI and see raw data (debug mode)")
debug = flag.Bool("debug", false, "Disable UI and see raw data (debug mode)")
interval = flag.Duration("i", 1*time.Second, "Update interval")
)
func main() {
@ -30,17 +31,19 @@ func main() {
continue
}
fmt.Println("CPU:", cpu)
time.Sleep(1 * time.Second)
time.Sleep(*interval)
}
return
}
data := NewData()
_ = data
ui := initUI(pid)
defer stopUI()
ui.HandleKeys()
ui.AddTimer(1*time.Second, func(e termui.Event) {
ui.AddTimer(*interval, func(e termui.Event) {
cpu, err := adbCPU(pid)
if err != nil {
return