From 2ce69e9701a3e9bd95be5210ad3b8f719ebbb3d2 Mon Sep 17 00:00:00 2001 From: Bill Date: Thu, 7 Jun 2018 15:10:22 -0700 Subject: [PATCH 01/14] added a basic logging module, and a basic log 'running' in wtf.go --- wtf.go | 2 ++ wtf/log.go | 26 ++++++++++++++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 wtf/log.go diff --git a/wtf.go b/wtf.go index 660e458c..306c00ff 100644 --- a/wtf.go +++ b/wtf.go @@ -253,4 +253,6 @@ func main() { fmt.Printf("An error occurred: %v\n", err) os.Exit(1) } + + wtf.Log("running!") } 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) +} From 9b7f31877d04f6687facd084bed4a55d499a463e Mon Sep 17 00:00:00 2001 From: Hossein Mehrabi Date: Fri, 8 Jun 2018 05:28:45 +0430 Subject: [PATCH 02/14] added Disable method --- wtf/enabler.go | 1 + wtf/text_widget.go | 4 ++++ 2 files changed, 5 insertions(+) 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/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 } From e00a0a81a06ea2ccd427b2d5b9fa8b54e197ecbe Mon Sep 17 00:00:00 2001 From: Hossein Mehrabi Date: Fri, 8 Jun 2018 05:31:59 +0430 Subject: [PATCH 03/14] disable all widgets before live-reloading --- wtf.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/wtf.go b/wtf.go index f0df2b06..da5e5afd 100644 --- a/wtf.go +++ b/wtf.go @@ -121,6 +121,8 @@ func watchForConfigChanges(app *tview.Application, configFlag string, grid *tvie select { case <-watch.Event: loadConfig(configFlag) + // Disable all widgets to stop scheduler goroutines and widgets from memory. + disableAllWidgets() makeWidgets(app, pages) grid = buildGrid(Widgets) pages.AddPage("grid", grid, true, true) @@ -155,6 +157,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 { From 2c4cf578ae3d7599bc5da3a124fcbf94e0876a88 Mon Sep 17 00:00:00 2001 From: Hossein Mehrabi Date: Fri, 8 Jun 2018 05:38:45 +0430 Subject: [PATCH 04/14] fixed comment --- wtf.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wtf.go b/wtf.go index da5e5afd..b9627490 100644 --- a/wtf.go +++ b/wtf.go @@ -121,7 +121,7 @@ func watchForConfigChanges(app *tview.Application, configFlag string, grid *tvie select { case <-watch.Event: loadConfig(configFlag) - // Disable all widgets to stop scheduler goroutines and widgets from memory. + // Disable all widgets to stop scheduler goroutines and rmeove widgets from memory. disableAllWidgets() makeWidgets(app, pages) grid = buildGrid(Widgets) From f33b756d023b37d85e2580206a79290d3ce3f659 Mon Sep 17 00:00:00 2001 From: Hossein Mehrabi Date: Fri, 8 Jun 2018 10:59:47 +0430 Subject: [PATCH 05/14] removed useless condition in Refresh --- bamboohr/widget.go | 4 ---- clocks/widget.go | 4 ---- cmdrunner/widget.go | 4 ---- cryptoexchanges/bittrex/widget.go | 4 ---- cryptoexchanges/cryptolive/widget.go | 4 ---- gcal/widget.go | 4 ---- git/widget.go | 4 ---- github/widget.go | 4 ---- ipinfo/widget.go | 4 ---- jira/widget.go | 4 ---- newrelic/widget.go | 4 ---- opsgenie/widget.go | 4 ---- power/widget.go | 4 ---- prettyweather/widget.go | 4 ---- security/widget.go | 4 ---- status/widget.go | 4 ---- system/widget.go | 4 ---- textfile/widget.go | 4 ---- todo/widget.go | 4 ---- weather/widget.go | 4 ---- 20 files changed, 80 deletions(-) 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..492b3050 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() 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() From f912d642793ce5d330c66bcd3042834dab008d9d Mon Sep 17 00:00:00 2001 From: Hossein Mehrabi Date: Fri, 8 Jun 2018 11:26:19 +0430 Subject: [PATCH 06/14] removed duplicate condition --- ipinfo/widget.go | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/ipinfo/widget.go b/ipinfo/widget.go index 95257c45..143932e5 100644 --- a/ipinfo/widget.go +++ b/ipinfo/widget.go @@ -73,10 +73,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 { From e453e9d52de8a3bbc691c36ca57d0d8816fe4d96 Mon Sep 17 00:00:00 2001 From: Chris Cummer Date: Fri, 8 Jun 2018 10:57:00 -0700 Subject: [PATCH 07/14] Simplify the bug report template --- .github/ISSUE_TEMPLATE/Bug.md | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/Bug.md b/.github/ISSUE_TEMPLATE/Bug.md index 25eef495..e7b1bd50 100644 --- a/.github/ISSUE_TEMPLATE/Bug.md +++ b/.github/ISSUE_TEMPLATE/Bug.md @@ -5,16 +5,10 @@ about: Something is broken? ### Bug Report -#### Summary - +#### What's the problem? -##### What is the current behaviour? - -### How to reproduce +#### How did you expect it to behave? -##### If the current behaviour is a bug, please provide the steps to reproduce it. - -##### What do you think the expected behaviour should be? - +#### How serious an issue do you think this is? From 5e0d064c59602bb756c35c7bc060a098db83b15c Mon Sep 17 00:00:00 2001 From: Chris Cummer Date: Fri, 8 Jun 2018 10:58:16 -0700 Subject: [PATCH 08/14] Simplify the feature request template --- .github/ISSUE_TEMPLATE/Feature.md | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/Feature.md b/.github/ISSUE_TEMPLATE/Feature.md index 9adde8b4..c0ce9be7 100644 --- a/.github/ISSUE_TEMPLATE/Feature.md +++ b/.github/ISSUE_TEMPLATE/Feature.md @@ -4,13 +4,12 @@ about: You have a neat idea that should be implemented? --- ### Feature Request - -| Q | A -|------------ | ------ -| New Feature | yes -| RFC | yes/no -| BC Break | yes/no -#### Summary - +#### What problem does this solve? + + +#### How do envision it working? + + +#### How important is this feature to you? From a36eeb4dc540f8306b0de711b7ad7bd1a61ab26c Mon Sep 17 00:00:00 2001 From: Chris Cummer Date: Fri, 8 Jun 2018 10:59:00 -0700 Subject: [PATCH 09/14] Simplify the support request template --- .github/ISSUE_TEMPLATE/Support.md | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/Support.md b/.github/ISSUE_TEMPLATE/Support.md index 8e127f00..b3129bbd 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 - +### Support Question +#### What problem are you having? From f0ef8cc091a8aa11c2c016511f330452b563bdf5 Mon Sep 17 00:00:00 2001 From: Chris Cummer Date: Fri, 8 Jun 2018 11:00:00 -0700 Subject: [PATCH 10/14] Simplify the pull request improvement template --- .github/PULL_REQUEST_TEMPLATE/Improvement.md | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/.github/PULL_REQUEST_TEMPLATE/Improvement.md b/.github/PULL_REQUEST_TEMPLATE/Improvement.md index 8b616076..cb540b02 100644 --- a/.github/PULL_REQUEST_TEMPLATE/Improvement.md +++ b/.github/PULL_REQUEST_TEMPLATE/Improvement.md @@ -4,13 +4,8 @@ about: You have some improvement to make wtf better? --- ### Improvement - -| Q | A -|------------ | ------ -| New Feature | yes -| RFC | yes/no -| BC Break | yes/no +#### What problem does this solve? -#### Summary - + +#### Is this related to an existing Issue? If so, which one? From 040c662a598f859bbdc2b9c67e8bf86d97b11a3f Mon Sep 17 00:00:00 2001 From: Chris Cummer Date: Fri, 8 Jun 2018 11:00:55 -0700 Subject: [PATCH 11/14] Simplify this template as well I suspect we can reduce these to one template. --- .github/PULL_REQUEST_TEMPLATE/Other.md | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/.github/PULL_REQUEST_TEMPLATE/Other.md b/.github/PULL_REQUEST_TEMPLATE/Other.md index 65da67ee..45985624 100644 --- a/.github/PULL_REQUEST_TEMPLATE/Other.md +++ b/.github/PULL_REQUEST_TEMPLATE/Other.md @@ -5,14 +5,4 @@ about: You have some other ideas you want to introduce? -**What kind of change does this PR introduce?** - - -**Summary** - - - -**Does this PR introduce a breaking change?** - - -**Other information** +#### What problem does this solve? From a856a7b7883340cdc038d0a53c169dec51e52b54 Mon Sep 17 00:00:00 2001 From: Chris Cummer Date: Fri, 8 Jun 2018 11:01:38 -0700 Subject: [PATCH 12/14] Further simplify the bug template --- .github/ISSUE_TEMPLATE/Bug.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/Bug.md b/.github/ISSUE_TEMPLATE/Bug.md index e7b1bd50..dcebb27d 100644 --- a/.github/ISSUE_TEMPLATE/Bug.md +++ b/.github/ISSUE_TEMPLATE/Bug.md @@ -10,5 +10,3 @@ about: Something is broken? #### How did you expect it to behave? - -#### How serious an issue do you think this is? From 4f2efae61944cf37e6b215264a852290c44ec32c Mon Sep 17 00:00:00 2001 From: Chris Cummer Date: Fri, 8 Jun 2018 11:02:10 -0700 Subject: [PATCH 13/14] Update Bug.md --- .github/ISSUE_TEMPLATE/Bug.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/Bug.md b/.github/ISSUE_TEMPLATE/Bug.md index dcebb27d..adda2996 100644 --- a/.github/ISSUE_TEMPLATE/Bug.md +++ b/.github/ISSUE_TEMPLATE/Bug.md @@ -3,8 +3,6 @@ name: Bug Report about: Something is broken? --- -### Bug Report - #### What's the problem? From 30aca0ae4ec128898ce08b2a5d299d5006f353de Mon Sep 17 00:00:00 2001 From: Chris Cummer Date: Fri, 8 Jun 2018 11:03:50 -0700 Subject: [PATCH 14/14] Mass-simplify the default templates --- .github/ISSUE_TEMPLATE/Feature.md | 4 ---- .github/ISSUE_TEMPLATE/Support.md | 4 ++-- .github/PULL_REQUEST_TEMPLATE/Improvement.md | 4 ++-- .github/PULL_REQUEST_TEMPLATE/Other.md | 5 ++++- 4 files changed, 8 insertions(+), 9 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/Feature.md b/.github/ISSUE_TEMPLATE/Feature.md index c0ce9be7..3d6ed228 100644 --- a/.github/ISSUE_TEMPLATE/Feature.md +++ b/.github/ISSUE_TEMPLATE/Feature.md @@ -3,13 +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? -#### How important is this feature to you? diff --git a/.github/ISSUE_TEMPLATE/Support.md b/.github/ISSUE_TEMPLATE/Support.md index b3129bbd..35d66b97 100644 --- a/.github/ISSUE_TEMPLATE/Support.md +++ b/.github/ISSUE_TEMPLATE/Support.md @@ -3,6 +3,6 @@ name: ❓ Support Question about: Have a problem that you can't figure out? --- -### Support Question +#### What problem are you having and how can we help? + -#### What problem are you having? diff --git a/.github/PULL_REQUEST_TEMPLATE/Improvement.md b/.github/PULL_REQUEST_TEMPLATE/Improvement.md index cb540b02..ef71c51d 100644 --- a/.github/PULL_REQUEST_TEMPLATE/Improvement.md +++ b/.github/PULL_REQUEST_TEMPLATE/Improvement.md @@ -3,9 +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? + + diff --git a/.github/PULL_REQUEST_TEMPLATE/Other.md b/.github/PULL_REQUEST_TEMPLATE/Other.md index 45985624..d6e0c64b 100644 --- a/.github/PULL_REQUEST_TEMPLATE/Other.md +++ b/.github/PULL_REQUEST_TEMPLATE/Other.md @@ -1,8 +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 problem does this solve? + + +