1
0
mirror of https://github.com/taigrr/wtf synced 2025-01-18 04:03:14 -08:00

Add default unknown widget

Let people know if they are doing something wrong
This commit is contained in:
Sean Smith 2019-02-14 22:30:14 -05:00
parent 8a4c3ac121
commit 90f150df3d
2 changed files with 33 additions and 0 deletions

View File

@ -57,6 +57,7 @@ import (
"github.com/wtfutil/wtf/travisci"
"github.com/wtfutil/wtf/trello"
"github.com/wtfutil/wtf/twitter"
"github.com/wtfutil/wtf/unknown"
"github.com/wtfutil/wtf/victorops"
"github.com/wtfutil/wtf/weatherservices/prettyweather"
"github.com/wtfutil/wtf/weatherservices/weather"
@ -259,6 +260,7 @@ func addWidget(app *tview.Application, pages *tview.Pages, widgetName string) {
case "zendesk":
widgets = append(widgets, zendesk.NewWidget(app))
default:
widgets = append(widgets, unknown.NewWidget(app, widgetName))
}
}

31
unknown/widget.go Normal file
View File

@ -0,0 +1,31 @@
package unknown
import (
"fmt"
"github.com/rivo/tview"
"github.com/wtfutil/wtf/wtf"
)
type Widget struct {
wtf.TextWidget
}
func NewWidget(app *tview.Application, name string) *Widget {
widget := Widget{
TextWidget: wtf.NewTextWidget(app, name, name, false),
}
return &widget
}
/* -------------------- Exported Functions -------------------- */
func (widget *Widget) Refresh() {
widget.View.SetTitle(widget.ContextualTitle(fmt.Sprintf("%s", widget.Name)))
widget.View.Clear()
content := fmt.Sprintf("Widget %s does not exist", widget.Name)
widget.View.SetText(content)
}