mirror of
https://github.com/taigrr/wtf
synced 2025-01-18 04:03:14 -08:00
YAML config added. App refreshInterval as first value
This commit is contained in:
parent
22a9f7b194
commit
39cf8c6e1c
@ -1,2 +1,2 @@
|
|||||||
wtf:
|
wtf:
|
||||||
refresh_interval: 1
|
refreshInterval: 1
|
||||||
|
@ -101,27 +101,23 @@ func Fetch() (*calendar.Events, error) {
|
|||||||
|
|
||||||
b, err := ioutil.ReadFile("./gcal/client_secret.json")
|
b, err := ioutil.ReadFile("./gcal/client_secret.json")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
//log.Fatalf("Unable to read client secret file: %v", err)
|
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
config, err := google.ConfigFromJSON(b, calendar.CalendarReadonlyScope)
|
config, err := google.ConfigFromJSON(b, calendar.CalendarReadonlyScope)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
//log.Fatalf("Unable to parse client secret file to config: %v", err)
|
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
client := getClient(ctx, config)
|
client := getClient(ctx, config)
|
||||||
|
|
||||||
srv, err := calendar.New(client)
|
srv, err := calendar.New(client)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
//log.Fatalf("Unable to retrieve calendar Client %v", err)
|
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
t := today().Format(time.RFC3339)
|
t := today().Format(time.RFC3339)
|
||||||
events, err := srv.Events.List("primary").ShowDeleted(false).SingleEvents(true).TimeMin(t).MaxResults(10).OrderBy("startTime").Do()
|
events, err := srv.Events.List("primary").ShowDeleted(false).SingleEvents(true).TimeMin(t).MaxResults(10).OrderBy("startTime").Do()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
//log.Fatalf("Unable to retrieve next ten of the user's events. %v", err)
|
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
15
wtf.go
15
wtf.go
@ -1,7 +1,7 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
//"fmt"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/olebedev/config"
|
"github.com/olebedev/config"
|
||||||
@ -16,6 +16,8 @@ import (
|
|||||||
"github.com/senorprogrammer/wtf/weather"
|
"github.com/senorprogrammer/wtf/weather"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var Config = loadConfig()
|
||||||
|
|
||||||
func loadConfig() *config.Config {
|
func loadConfig() *config.Config {
|
||||||
cfg, err := config.ParseYamlFile("./config.yml")
|
cfg, err := config.ParseYamlFile("./config.yml")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -26,7 +28,12 @@ func loadConfig() *config.Config {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func refresher(stat *status.Widget, app *tview.Application) {
|
func refresher(stat *status.Widget, app *tview.Application) {
|
||||||
tick := time.NewTicker(1 * time.Second)
|
refreshInterval, err := Config.Int("wtf.refresh_interval")
|
||||||
|
if err != nil {
|
||||||
|
refreshInterval = 1
|
||||||
|
}
|
||||||
|
|
||||||
|
tick := time.NewTicker(time.Duration(refreshInterval) * time.Second)
|
||||||
quit := make(chan struct{})
|
quit := make(chan struct{})
|
||||||
|
|
||||||
for {
|
for {
|
||||||
@ -41,10 +48,6 @@ func refresher(stat *status.Widget, app *tview.Application) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
cfg := loadConfig()
|
|
||||||
|
|
||||||
fmt.Printf("%v\n", cfg)
|
|
||||||
|
|
||||||
bamboo := bamboohr.NewWidget()
|
bamboo := bamboohr.NewWidget()
|
||||||
bamboo.Refresh()
|
bamboo.Refresh()
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user