diff --git a/.github/ISSUE_TEMPLATE/Bug.md b/.github/ISSUE_TEMPLATE/Bug.md index 25eef495..adda2996 100644 --- a/.github/ISSUE_TEMPLATE/Bug.md +++ b/.github/ISSUE_TEMPLATE/Bug.md @@ -3,18 +3,8 @@ name: Bug Report about: Something is broken? --- -### Bug Report +#### What's the problem? -#### Summary - -##### What is the current behaviour? - +#### How did you expect it to behave? -### How to reproduce - -##### If the current behaviour is a bug, please provide the steps to reproduce it. - - -##### What do you think the expected behaviour should be? - diff --git a/.github/ISSUE_TEMPLATE/Feature.md b/.github/ISSUE_TEMPLATE/Feature.md index 9adde8b4..3d6ed228 100644 --- a/.github/ISSUE_TEMPLATE/Feature.md +++ b/.github/ISSUE_TEMPLATE/Feature.md @@ -3,14 +3,9 @@ name: Feature Request about: You have a neat idea that should be implemented? --- -### Feature Request - +#### What problem does this solve? + + +#### How do envision it working? -| Q | A -|------------ | ------ -| New Feature | yes -| RFC | yes/no -| BC Break | yes/no -#### Summary - diff --git a/.github/ISSUE_TEMPLATE/Support.md b/.github/ISSUE_TEMPLATE/Support.md index 8e127f00..35d66b97 100644 --- a/.github/ISSUE_TEMPLATE/Support.md +++ b/.github/ISSUE_TEMPLATE/Support.md @@ -3,9 +3,6 @@ name: ❓ Support Question about: Have a problem that you can't figure out? --- -| Q | A -|------------ | ----- -| Version | 0.0.4 -#### Support Question - +#### What problem are you having and how can we help? + diff --git a/.github/PULL_REQUEST_TEMPLATE/Improvement.md b/.github/PULL_REQUEST_TEMPLATE/Improvement.md index 8b616076..ef71c51d 100644 --- a/.github/PULL_REQUEST_TEMPLATE/Improvement.md +++ b/.github/PULL_REQUEST_TEMPLATE/Improvement.md @@ -3,14 +3,9 @@ name: Improvement about: You have some improvement to make wtf better? --- -### Improvement - +#### What problem does this solve? + + +#### Is this related to an existing Issue? If so, which one? -| Q | A -|------------ | ------ -| New Feature | yes -| RFC | yes/no -| BC Break | yes/no -#### Summary - diff --git a/.github/PULL_REQUEST_TEMPLATE/Other.md b/.github/PULL_REQUEST_TEMPLATE/Other.md index 65da67ee..d6e0c64b 100644 --- a/.github/PULL_REQUEST_TEMPLATE/Other.md +++ b/.github/PULL_REQUEST_TEMPLATE/Other.md @@ -1,18 +1,11 @@ --- name: Other -about: You have some other ideas you want to introduce? +about: You have some other ideas you want to introduce? --- -**What kind of change does this PR introduce?** - +#### What problem does this solve? -**Summary** - - -**Does this PR introduce a breaking change?** - -**Other information** diff --git a/bamboohr/widget.go b/bamboohr/widget.go index 5876f567..1e9eb751 100644 --- a/bamboohr/widget.go +++ b/bamboohr/widget.go @@ -25,10 +25,6 @@ func NewWidget() *Widget { /* -------------------- Exported Functions -------------------- */ func (widget *Widget) Refresh() { - if widget.Disabled() { - return - } - client := NewClient("https://api.bamboohr.com/api/gateway.php") todayItems := client.Away( "timeOff", diff --git a/clocks/widget.go b/clocks/widget.go index 0e1a7fdc..d6d6ee2a 100644 --- a/clocks/widget.go +++ b/clocks/widget.go @@ -29,10 +29,6 @@ func NewWidget() *Widget { /* -------------------- Exported Functions -------------------- */ func (widget *Widget) Refresh() { - if widget.Disabled() { - return - } - widget.UpdateRefreshedAt() widget.display(widget.clockColl.Sorted()) } diff --git a/cmdrunner/widget.go b/cmdrunner/widget.go index 3c80ae5a..0708527e 100644 --- a/cmdrunner/widget.go +++ b/cmdrunner/widget.go @@ -34,10 +34,6 @@ func NewWidget() *Widget { } func (widget *Widget) Refresh() { - if widget.Disabled() { - return - } - widget.UpdateRefreshedAt() widget.execute() widget.View.SetTitle(fmt.Sprintf(" %s ", widget)) diff --git a/cryptoexchanges/bittrex/widget.go b/cryptoexchanges/bittrex/widget.go index 7bb83b3a..7bbf1003 100644 --- a/cryptoexchanges/bittrex/widget.go +++ b/cryptoexchanges/bittrex/widget.go @@ -100,10 +100,6 @@ func makeMarketCurrency(name string) *mCurrency { // Refresh & update after interval time func (widget *Widget) Refresh() { - if widget.Disabled() { - return - } - widget.updateSummary() widget.UpdateRefreshedAt() widget.display() diff --git a/cryptoexchanges/cryptolive/widget.go b/cryptoexchanges/cryptolive/widget.go index 732f6863..daaefa0e 100644 --- a/cryptoexchanges/cryptolive/widget.go +++ b/cryptoexchanges/cryptolive/widget.go @@ -38,10 +38,6 @@ func NewWidget() *Widget { // Refresh & update after interval time func (widget *Widget) Refresh() { - if widget.Disabled() { - return - } - widget.updateCurrencies() widget.UpdateRefreshedAt() diff --git a/gcal/widget.go b/gcal/widget.go index 3b343627..487c8daa 100644 --- a/gcal/widget.go +++ b/gcal/widget.go @@ -29,10 +29,6 @@ func NewWidget() *Widget { /* -------------------- Exported Functions -------------------- */ func (widget *Widget) Refresh() { - if widget.Disabled() { - return - } - events, _ := Fetch() widget.UpdateRefreshedAt() diff --git a/git/widget.go b/git/widget.go index 850d3bfd..89aad5a2 100644 --- a/git/widget.go +++ b/git/widget.go @@ -49,10 +49,6 @@ func NewWidget(app *tview.Application, pages *tview.Pages) *Widget { /* -------------------- Exported Functions -------------------- */ func (widget *Widget) Refresh() { - if widget.Disabled() { - return - } - repoPaths := wtf.ToStrs(Config.UList("wtf.mods.git.repositories")) widget.UpdateRefreshedAt() diff --git a/github/widget.go b/github/widget.go index ad186310..717f1bab 100644 --- a/github/widget.go +++ b/github/widget.go @@ -51,10 +51,6 @@ func NewWidget(app *tview.Application, pages *tview.Pages) *Widget { /* -------------------- Exported Functions -------------------- */ func (widget *Widget) Refresh() { - if widget.Disabled() { - return - } - for _, repo := range widget.GithubRepos { repo.Refresh() } diff --git a/ipinfo/widget.go b/ipinfo/widget.go index 95257c45..62db1732 100644 --- a/ipinfo/widget.go +++ b/ipinfo/widget.go @@ -47,10 +47,6 @@ func NewWidget() *Widget { } func (widget *Widget) Refresh() { - if widget.Disabled() { - return - } - widget.UpdateRefreshedAt() widget.ipinfo() widget.View.Clear() @@ -73,10 +69,7 @@ func (widget *Widget) ipinfo() { return } defer response.Body.Close() - if err != nil { - widget.result = fmt.Sprintf("%s", err.Error()) - return - } + var info ipinfo err = json.NewDecoder(response.Body).Decode(&info) if err != nil { diff --git a/jira/widget.go b/jira/widget.go index d9fe19f1..126c629d 100644 --- a/jira/widget.go +++ b/jira/widget.go @@ -25,10 +25,6 @@ func NewWidget() *Widget { /* -------------------- Exported Functions -------------------- */ func (widget *Widget) Refresh() { - if widget.Disabled() { - return - } - searchResult, err := IssuesFor(Config.UString("wtf.mods.jira.username"), Config.UString("wtf.mods.jira.project", ""), Config.UString("wtf.mods.jira.jql", "")) widget.UpdateRefreshedAt() diff --git a/newrelic/widget.go b/newrelic/widget.go index 2831ea08..ca16966f 100644 --- a/newrelic/widget.go +++ b/newrelic/widget.go @@ -26,10 +26,6 @@ func NewWidget() *Widget { /* -------------------- Exported Functions -------------------- */ func (widget *Widget) Refresh() { - if widget.Disabled() { - return - } - app, appErr := Application() deploys, depErr := Deployments() diff --git a/opsgenie/widget.go b/opsgenie/widget.go index bf72c006..314b832a 100644 --- a/opsgenie/widget.go +++ b/opsgenie/widget.go @@ -26,10 +26,6 @@ func NewWidget() *Widget { /* -------------------- Exported Functions -------------------- */ func (widget *Widget) Refresh() { - if widget.Disabled() { - return - } - data, err := Fetch() widget.UpdateRefreshedAt() diff --git a/power/widget.go b/power/widget.go index dc98d6ae..d3d3a996 100644 --- a/power/widget.go +++ b/power/widget.go @@ -28,10 +28,6 @@ func NewWidget() *Widget { } func (widget *Widget) Refresh() { - if widget.Disabled() { - return - } - widget.UpdateRefreshedAt() widget.Battery.Refresh() diff --git a/prettyweather/widget.go b/prettyweather/widget.go index 5cb61446..c0ef7596 100644 --- a/prettyweather/widget.go +++ b/prettyweather/widget.go @@ -30,10 +30,6 @@ func NewWidget() *Widget { } func (widget *Widget) Refresh() { - if widget.Disabled() { - return - } - widget.UpdateRefreshedAt() widget.prettyWeather() diff --git a/security/widget.go b/security/widget.go index a6161fd9..f5769b8e 100644 --- a/security/widget.go +++ b/security/widget.go @@ -26,10 +26,6 @@ func NewWidget() *Widget { /* -------------------- Exported Functions -------------------- */ func (widget *Widget) Refresh() { - if widget.Disabled() { - return - } - data := NewSecurityData() data.Fetch() diff --git a/status/widget.go b/status/widget.go index 6550fe5f..3bd71599 100644 --- a/status/widget.go +++ b/status/widget.go @@ -28,10 +28,6 @@ func NewWidget() *Widget { /* -------------------- Exported Functions -------------------- */ func (widget *Widget) Refresh() { - if widget.Disabled() { - return - } - widget.UpdateRefreshedAt() widget.View.SetText( diff --git a/system/widget.go b/system/widget.go index 29f9efd0..c13ed5ea 100644 --- a/system/widget.go +++ b/system/widget.go @@ -33,10 +33,6 @@ func NewWidget(date, version string) *Widget { } func (widget *Widget) Refresh() { - if widget.Disabled() { - return - } - widget.UpdateRefreshedAt() widget.View.SetText( diff --git a/textfile/widget.go b/textfile/widget.go index d581dc4f..2bc3afe6 100644 --- a/textfile/widget.go +++ b/textfile/widget.go @@ -48,10 +48,6 @@ func NewWidget(app *tview.Application, pages *tview.Pages) *Widget { /* -------------------- Exported Functions -------------------- */ func (widget *Widget) Refresh() { - if widget.Disabled() { - return - } - widget.UpdateRefreshedAt() widget.View.SetTitle(fmt.Sprintf("%s %s", widget.Name, widget.filePath)) diff --git a/todo/widget.go b/todo/widget.go index f0b15503..00dcb984 100644 --- a/todo/widget.go +++ b/todo/widget.go @@ -61,10 +61,6 @@ func NewWidget(app *tview.Application, pages *tview.Pages) *Widget { /* -------------------- Exported Functions -------------------- */ func (widget *Widget) Refresh() { - if widget.Disabled() { - return - } - widget.UpdateRefreshedAt() widget.load() widget.display() diff --git a/weather/widget.go b/weather/widget.go index c9fba361..992c7207 100644 --- a/weather/widget.go +++ b/weather/widget.go @@ -74,10 +74,6 @@ func (widget *Widget) Fetch(cityIDs []int) []*owm.CurrentWeatherData { // Refresh fetches new data from the OpenWeatherMap API and loads the new data into the. // widget's view for rendering func (widget *Widget) Refresh() { - if widget.Disabled() { - return - } - widget.Data = widget.Fetch(wtf.ToInts(Config.UList("wtf.mods.weather.cityids", widget.defaultCityCodes()))) widget.UpdateRefreshedAt() diff --git a/wtf.go b/wtf.go index 9dba4ae3..7ecc536d 100644 --- a/wtf.go +++ b/wtf.go @@ -122,6 +122,8 @@ func watchForConfigChanges(app *tview.Application, configFlag string, grid *tvie select { case <-watch.Event: loadConfig(configFlag) + // Disable all widgets to stop scheduler goroutines and rmeove widgets from memory. + disableAllWidgets() makeWidgets(app, pages) grid = buildGrid(Widgets) pages.AddPage("grid", grid, true, true) @@ -156,6 +158,12 @@ var ( version = "dev" ) +func disableAllWidgets() { + for _, widget := range Widgets { + widget.Disable() + } +} + func addWidget(app *tview.Application, pages *tview.Pages, widgetName string) { // Always in alphabetical order switch widgetName { @@ -288,4 +296,6 @@ func main() { fmt.Printf("An error occurred: %v\n", err) os.Exit(1) } + + wtf.Log("running!") } diff --git a/wtf/enabler.go b/wtf/enabler.go index 26ec5a21..c7a5b973 100644 --- a/wtf/enabler.go +++ b/wtf/enabler.go @@ -3,4 +3,5 @@ package wtf type Enabler interface { Disabled() bool Enabled() bool + Disable() } diff --git a/wtf/log.go b/wtf/log.go new file mode 100644 index 00000000..eaada6f6 --- /dev/null +++ b/wtf/log.go @@ -0,0 +1,26 @@ +package wtf + +import ( + "log" + "os" + "path/filepath" +) + +//Log basic message logging, defaults to ~/.wtf/log.txt +func Log(message string) { + + dir, err := Home() + if err != nil { + return + } + + logfile := filepath.Join(dir, ".wtf", "log.txt") + f, err := os.OpenFile(logfile, os.O_RDWR|os.O_CREATE|os.O_APPEND, 0666) + if err != nil { + log.Fatalf("error opening file: %v", err) + } + defer f.Close() + + log.SetOutput(f) + log.Println(message) +} diff --git a/wtf/text_widget.go b/wtf/text_widget.go index 8c7f864d..b62868ef 100644 --- a/wtf/text_widget.go +++ b/wtf/text_widget.go @@ -61,6 +61,10 @@ func (widget *TextWidget) Enabled() bool { return widget.enabled } +func (widget *TextWidget) Disable() { + widget.enabled = false +} + func (widget *TextWidget) Focusable() bool { return widget.enabled && widget.focusable }