diff --git a/bamboohr/widget.go b/bamboohr/widget.go index 1551c43e..13b5d124 100644 --- a/bamboohr/widget.go +++ b/bamboohr/widget.go @@ -60,13 +60,13 @@ func (widget *Widget) contentFrom(items []Item) string { str := "" for _, item := range items { - str = str + widget.display(item) + str = str + widget.format(item) } return str } -func (widget *Widget) display(item Item) string { +func (widget *Widget) format(item Item) string { var str string if item.IsOneDay() { diff --git a/opsgenie/client.go b/opsgenie/client.go new file mode 100644 index 00000000..3ebf5335 --- /dev/null +++ b/opsgenie/client.go @@ -0,0 +1,33 @@ +package opsgenie + +import ( + "os" + + ogcli "github.com/opsgenie/opsgenie-go-sdk/client" + sch "github.com/opsgenie/opsgenie-go-sdk/schedule" +) + +func Fetch() string { + apiKey := os.Getenv("WTF_OPS_GENIE_API_KEY") + + cli := new(ogcli.OpsGenieClient) + cli.SetAPIKey(apiKey) + + scheduler, err := cli.Schedule() + if err != nil { + panic(err) + } + + request := sch.ListSchedulesRequest{} + response, err := scheduler.List(request) + if err != nil { + panic(err) + } + + var str string + for _, schedule := range response.Schedules { + str = str + schedule.Name + "\n" + } + + return "" +} diff --git a/opsgenie/widget.go b/opsgenie/widget.go index e6b889f5..b1b77313 100644 --- a/opsgenie/widget.go +++ b/opsgenie/widget.go @@ -1,7 +1,7 @@ package opsgenie import ( - "fmt" + //"fmt" "time" "github.com/rivo/tview" @@ -31,11 +31,13 @@ func NewWidget() *Widget { /* -------------------- Exported Functions -------------------- */ func (widget *Widget) Refresh() { + //data := Fetch() + widget.View.SetTitle(" OpsGenie ") widget.RefreshedAt = time.Now() widget.View.Clear() - fmt.Fprintf(widget.View, "%s", "opsgenie") + //fmt.Fprintf(widget.View, "%s", widget.contentFrom(data)) } /* -------------------- Unexported Functions -------------------- */ @@ -49,3 +51,7 @@ func (widget *Widget) addView() { widget.View = view } + +func (widget *Widget) contentFrom(data string) string { + return data +} diff --git a/weather/client.go b/weather/client.go index b478ab1f..3725d62b 100644 --- a/weather/client.go +++ b/weather/client.go @@ -7,12 +7,14 @@ import ( ) func Fetch() *owm.CurrentWeatherData { - w, err := owm.NewCurrent("C", "EN", os.Getenv("WTF_OWM_API_KEY")) + apiKey := os.Getenv("WTF_OWM_API_KEY") + + weather, err := owm.NewCurrent("C", "EN", apiKey) if err != nil { panic(err) } - w.CurrentByID(6173331) + weather.CurrentByID(6173331) - return w + return weather } diff --git a/wtf/utils.go b/wtf/utils.go index bf36bbe9..c970d574 100644 --- a/wtf/utils.go +++ b/wtf/utils.go @@ -25,5 +25,7 @@ func ExecuteCommand(cmd *exec.Cmd) string { str += string(b) } + cmd.Wait() + return str }