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

Compare commits

...

208 Commits

Author SHA1 Message Date
dependabot-preview[bot]
e86b77131a
Upgrade to GitHub-native Dependabot (#1084)
Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>
2021-05-11 22:39:36 -07:00
Chris Cummer
91942b68f2
Update LICENSE.md 2021-04-15 15:26:23 -07:00
Chris Cummer
65aa2c9877 Fix golangci-lint.yaml
Signed-off-by: Chris Cummer <chriscummer@me.com>
2021-04-13 04:20:35 -07:00
Chris Cummer
971fcee8db Remove references to 'refreshInterval'
Signed-off-by: Chris Cummer <chriscummer@me.com>
2021-04-11 19:25:02 -07:00
Chris Cummer
46389463f3 Add @cclauss as a contributor 2021-04-11 13:23:03 -07:00
Christian Clauss
a85e61f5f9
Upgrade golangci to v1.39 (#1074) 2021-04-11 13:21:58 -07:00
Chris Cummer
dadbb8c8f4
Update CHANGELOG.md 2021-03-27 19:31:54 -07:00
Chris Cummer
8eb4a25891
WTF-1070 Read response body data before closing (#1071)
Signed-off-by: Chris Cummer <chriscummer@me.com>
2021-03-27 19:30:18 -07:00
Chris Cummer
2fd9d623a1 Regenerate all-contributors
Signed-off-by: Chris Cummer <chriscummer@me.com>
2021-03-27 14:02:43 -07:00
Chris Cummer
3592ba45ca Add @inetAnt as a contributor 2021-03-27 14:01:41 -07:00
Chris Cummer
0b4b503086
Update CHANGELOG.md 2021-03-27 13:43:24 -07:00
Antoine Meillet
9fb57845ed
Add Yahoo Finance module (#1066)
* Move finnhub to a stocks folder

As I am preparing an other stocks data provider, let's move `finnhub` to
a stocks folder that will host the others providers.

* Use go-pretty v6

Will be used by the new stock provider module, so let's just upgrade
this one to reduce the number of dependencies.

* Add Yahoo Finance module

Yahoo Finance provides an API for which `piquette/finance-go` is a
powerful client. This new module leverages this module to integrate all
indices provided by Yahoo Finance (international stocks, crypto,
options, currencies...)

Sample config:
```yaml
    yfinance:
      title: "Stocks 🚀"
      symbols:
        - "MSFT"
        - "GC=F"
        - "ORA.PA"
      sort: true
      enabled: true
      refreshInterval: 60
      position:
        top: 1
        left: 0
        height: 1
        width: 1
```
2021-03-27 13:42:28 -07:00
Chris Cummer
ac0aafc04d
Update CHANGELOG.md 2021-03-23 03:40:23 -07:00
Chris Cummer
4d2027d983 Attempt to fix the gorelease configuration
Signed-off-by: Chris Cummer <chriscummer@me.com>
2021-03-23 03:32:28 -07:00
Chris Cummer
a22c197d9b
Update CHANGELOG.md 2021-03-23 03:20:14 -07:00
David Bouchare
2ec2fc37a5
Fix defer execution (#1065) 2021-03-23 03:19:29 -07:00
Chris Cummer
f71a326fe2
Update CHANGELOG.md 2021-03-19 21:46:39 -07:00
Lukas Kämmerling
f844ff3afb
Update to Go 1.16 (#1064)
This commit updates the used Go version to 1.16. The biggest benefit from this is that with Go 1.16 (and the latest Goreleaser) support for Apple Silicon is available, therefore wtf would work on Apple Silicon.

Signed-off-by: Lukas Kämmerling <lukas.kaemmerling@hetzner-cloud.de>
2021-03-19 21:45:23 -07:00
Chris Cummer
582557e408
Update CHANGELOG.md 2021-03-19 21:44:53 -07:00
Lukas Kämmerling
9446886b37
Fix HackerNews Widget (#1063)
After commit 49109c77f719cedc5c7f15bcf255f952d2c3b90d the HackerNews widget did not work as expected. It failed with a error message "http: read on closed response body". This commit fixes the underlying reader issue by reading the whole request body within the apiRequest function and returning the []bytes of the response instead of *http.Response. If we want to continue to return *http.Response this would lead to the problem that the caller (GetStory() and GetStories()) always need to close the Request Body. The ways before this MR is a bit problematic because the defer gets executed when the function is "done", so it closes the Body already before the utils.ParseJSON can read it.

Signed-off-by: Lukas Kämmerling <lukas.kaemmerling@hetzner-cloud.de>
2021-03-19 21:43:54 -07:00
Chris Cummer
0035e479c8
Update CHANGELOG.md 2021-03-18 22:01:18 -07:00
Chris Cummer
6f0605d145 Add @LKaemmerling as a contributor 2021-03-18 21:59:56 -07:00
Lukas Kämmerling
0a89786826
Enhance Kubernetes module with Replica Count (Deployments) (#1062)
This commit adds the ReadyReplicas and Total Replicas count, the information is useful if you want to look over a new release of your application and k8s and want to know how many pods are ready/started from k8s. Otherwise the deployment option of this module is not that useful.

Signed-off-by: Lukas Kämmerling <lukas.kaemmerling@hetzner-cloud.de>
2021-03-18 21:57:40 -07:00
David Bouchare
02db55a136
Fix city key (#1061)
* Fix city

* Trigger Build to see if lint is still failing
2021-03-15 20:27:49 -07:00
Chris Cummer
15769f21d0
WTF-1057 Use long-form git SHA in staticcheck github action (#1058)
Signed-off-by: Chris Cummer <chriscummer@me.com>
2021-03-01 08:55:08 -08:00
David Bouchare
cf3229e0cd
Add a few more tests (#1056)
* Add test for SumInts()

* Add a few more tests in utils

* Minor update for SumInts test
2021-03-01 08:33:42 -08:00
Chris Cummer
7c12523139 Add @xntrik as a contributor 2021-02-04 00:52:26 -08:00
Chris Cummer
369a59e25d
Update CHANGELOG.md 2021-02-04 00:51:45 -08:00
Christian Frichot
a8b0fa897a
Add Asana Module (#1052)
* Add Asana Module

* Add Asana Module to the widget_maker

* Asana Module - addressing linting concerns

* Asana Module - ran go mod tidy
2021-02-04 00:51:03 -08:00
David Bouchare
6ecec4f149
Update test (#1050) 2021-01-24 20:49:10 -08:00
Chris Cummer
f48b17269c Add @pgaxatte as a contributor 2021-01-22 10:03:10 -08:00
Pierre Gaxatte
6fcd74bb82
Fix documentation links to wtfutil.com (#1048) 2021-01-22 10:02:01 -08:00
Fredrik Steen
ddfc439c41
Fix for potential runtime panic (#1046)
Switch error checking around, so we don't check the StatusCode before
handling client errors.
2021-01-20 09:03:27 -08:00
Chris Cummer
7c3d476def
Update CHANGELOG.md 2021-01-16 12:37:35 -08:00
David Bouchare
49109c77f7
[several modules] Close the response body (#1040) 2021-01-16 12:36:29 -08:00
Chris Cummer
a5f66588e7
Update CHANGELOG.md 2021-01-16 12:35:44 -08:00
Fredrik Steen
2341446376 Healthcecks module
Healthchecks.io is a service for monitoring cron jobs and similar
periodic processes.

Hosted: https://healthchecks.io/
API-Doc: https://healthchecks.io/docs/api/
GitHub: https://github.com/healthchecks/healthchecks

This module can be used both with hosted and self-hosted healthchecks.
2021-01-16 12:33:15 -08:00
Chris Cummer
9a703dd78b Deleted the Finnhub client test. It requires an API key to pass, and thats not acceptible
Signed-off-by: Chris Cummer <chriscummer@me.com>
2021-01-16 12:32:52 -08:00
Chris Cummer
767a18ad86
Update CHANGELOG.md 2021-01-03 13:57:17 -08:00
Chris Cummer
f55024b352
Update CHANGELOG.md 2021-01-03 13:56:56 -08:00
Chris Cummer
4b8b735a46 Add @zye1996 as a contributor 2021-01-03 10:35:23 -08:00
Chris Cummer
8068ffeb7d
Update CHANGELOG.md 2021-01-03 10:34:44 -08:00
zye1996
5783473cfa
fix requests url for cryptolive (#1042)
Co-authored-by: yzy <zhenyi@sensor.com>
2021-01-03 10:32:37 -08:00
Chris Cummer
d341c21f4b
Add support for the 'language' setting in the covid module (#1039)
Signed-off-by: Chris Cummer <chriscummer@me.com>
2020-12-29 13:46:08 -08:00
Chris Cummer
b434e79b9b
Update CHANGELOG.md 2020-12-29 13:37:50 -08:00
David Bouchare
2f2df04478
[modules] Add new covid tracker module (#1037)
* Add draft of covid module

* Work on pointers

* Add country stats

* Remove recovered, stays at 0

* Handle response code

* One struct for both

* List of countries

* Add test

* Add test for countries

* Fix typos

* Format numbers based on language/locale
2020-12-29 13:33:14 -08:00
Chris Cummer
d7da659b8b
Add support for user-configuration language tag specification. (#1038)
Adds a new top-level configuration key called "language":

```yaml
wtf:
  langauge: "ja-JP"
```

Users can now define which BCP 47 language tag to use to format any
text or numbers that currently support localization. Defaults to
"en-CA".

Acceptible values: any BCP 47 language tag recognized by the Go
"language" package.

Good luck to you figuring out what that cannonical list is. After a
morning of trying to suss it out, I have no idea.

Signed-off-by: Chris Cummer <chriscummer@me.com>
2020-12-29 12:14:20 -08:00
Chris Cummer
fd794707cd
☢️ WTF-1031 Support multiple simultaneous configurations (#1032)
* WTF-1031 Rename WtfApp.app to WtfApp.tviewApp

Signed-off-by: Chris Cummer <chriscummer@me.com>

* WTF-1031 Add scaffolding for main to support multiple WtfApp instances

Signed-off-by: Chris Cummer <chriscummer@me.com>

* WTF-1031 WIP

Signed-off-by: Chris Cummer <chriscummer@me.com>

* Remove common functionality from KeyboardWidget and into Base

Signed-off-by: Chris Cummer <chriscummer@me.com>

* Augment with some descriptive comments

Signed-off-by: Chris Cummer <chriscummer@me.com>

* Add full support for multiple app instances via the AppManager.

Still to do:

* Config support for multiple apps/multiple config files
* The ability to switch between apps

Signed-off-by: Chris Cummer <chriscummer@me.com>

* Move SetTerminal out of main and into its own file

Signed-off-by: Chris Cummer <chriscummer@me.com>
2020-12-21 03:25:41 -08:00
David Bouchare
9ba22f656b
Close the response body (#1036) 2020-12-18 20:20:05 -08:00
Chris Cummer
c41411b97e Fix the goreleaser action 'on' clause
Signed-off-by: Chris Cummer <chriscummer@me.com>
2020-12-06 11:38:15 -08:00
Chris Cummer
56469d8db3
Add goreleaser github action (#1035)
Creates a new release when a new tag is pushed up to GitHub.

Signed-off-by: Chris Cummer <chriscummer@me.com>
2020-12-06 11:36:32 -08:00
Chris Cummer
4cde3c7781
Update CHANGELOG.md 2020-12-02 13:56:33 -08:00
Chris Cummer
2246300740 Add @stone as a contributor 2020-12-02 13:55:17 -08:00
Chris Cummer
190b06182f Merge branch 'kris' of github.com:stone/wtf into stone-kris 2020-12-02 13:53:55 -08:00
David Bouchare
b2168be56e
Edit comment (#1033) 2020-12-02 13:52:06 -08:00
Fredrik Steen
cf808dd09b Fix inconsistent configuration name. 2020-11-30 17:44:28 +01:00
Fredrik Steen
90d672b2f2 Add krisinformation module
A module to parse the feed from: https://www.krisinformation.se/en

 Krisinformation.se is a web site run by the Swedish Civil Contingencies Agency
that compiles and convey warnings, alerts, and emergency information from
Swedish authorities to the public.

Features:

 - Filter on country (all messages)
 - Filter on county (only show county specific messages)
 - Distance (only show message within a certain distance)
 - Set a max age for displaying messages
 - Set a maximum number of messages displayed
2020-11-30 16:26:51 +01:00
Chris Cummer
68906edf49
Update CHANGELOG.md 2020-11-27 10:54:18 -08:00
Chris Cummer
14729b2bfd
Update CHANGELOG.md 2020-11-27 10:53:32 -08:00
Chris Cummer
20a8c1aa9c
Update CHANGELOG.md 2020-11-27 10:53:23 -08:00
Chris Cummer
e195453573 Use explicit documentation paths for modules that are nested into subdirectories
Signed-off-by: Chris Cummer <chriscummer@me.com>
2020-11-26 23:18:46 -08:00
Chris Cummer
d6a0797bf2 Simplify the inclusion of the Common config settings into each module
Signed-off-by: Chris Cummer <chriscummer@me.com>
2020-11-26 23:18:46 -08:00
Chris Cummer
f9a06540f1 Simplify the view loading for the keyboard widget
Signed-off-by: Chris Cummer <chriscummer@me.com>
2020-11-26 23:12:15 -08:00
Chris Cummer
4a820dd0e5 Make every widget a keyboard widget
Signed-off-by: Chris Cummer <chriscummer@me.com>
2020-11-26 23:12:15 -08:00
Chris Cummer
2430fe9f56 Opening docs in browser is working, but only for keyboard modules
This needs to work for all modules, which means effectively
every module just became a keyboard module, if it is focusable.

That's an interesting development.

Signed-off-by: Chris Cummer <chriscummer@me.com>
2020-11-26 23:12:15 -08:00
Chris Cummer
3521ebf6e8 Rename SigilStr to PaginationMarker
Signed-off-by: Chris Cummer <chriscummer@me.com>
2020-11-26 23:07:30 -08:00
Chris Cummer
a18f77bfad
Back onto grandcolline/golang-github-actions (#1030)
Signed-off-by: Chris Cummer <chriscummer@me.com>
2020-11-26 21:06:11 -08:00
Chris Cummer
7e0f10223c
Update CHANGELOG.md 2020-11-21 18:26:29 -08:00
Chris Cummer
727b6f5a58 Add @dabcoder as a contributor 2020-11-21 18:23:11 -08:00
David Bouchare
aae1cf55cc
[CircleCI] Add configurable number of builds to settings (#1025)
* Add configurable build number to settings

* Review feedback: number of builds
2020-11-21 18:21:02 -08:00
Chris Cummer
acfafb0607
Update CHANGELOG.md 2020-11-08 16:26:20 -08:00
Chris Cummer
9abd6a60fa go mod tidy
Signed-off-by: Chris Cummer <chriscummer@me.com>
2020-11-08 16:19:13 -08:00
Chris Cummer
234e36bd7e
Update CHANGELOG.md 2020-11-08 16:18:51 -08:00
dependabot-preview[bot]
1d38174162
Bump golang.org/x/text from 0.3.3 to 0.3.4 (#1014)
Bumps [golang.org/x/text](https://github.com/golang/text) from 0.3.3 to 0.3.4.
- [Release notes](https://github.com/golang/text/releases)
- [Commits](https://github.com/golang/text/compare/v0.3.3...v0.3.4)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>

Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>
2020-11-08 16:18:30 -08:00
dependabot-preview[bot]
7fbf21d700
Bump github.com/zorkian/go-datadog-api (#1010)
Bumps [github.com/zorkian/go-datadog-api](https://github.com/zorkian/go-datadog-api) from 2.29.0+incompatible to 2.30.0+incompatible.
- [Release notes](https://github.com/zorkian/go-datadog-api/releases)
- [Commits](https://github.com/zorkian/go-datadog-api/compare/v2.29.0...v2.30.0)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>

Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>
2020-11-08 16:17:55 -08:00
dependabot-preview[bot]
ab2df7e10c
Bump github.com/xanzy/go-gitlab from 0.38.2 to 0.39.0 (#1013)
Bumps [github.com/xanzy/go-gitlab](https://github.com/xanzy/go-gitlab) from 0.38.2 to 0.39.0.
- [Release notes](https://github.com/xanzy/go-gitlab/releases)
- [Changelog](https://github.com/xanzy/go-gitlab/blob/master/CHANGELOG.md)
- [Commits](https://github.com/xanzy/go-gitlab/compare/v0.38.2...v0.39.0)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>

Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>
2020-11-08 16:17:28 -08:00
dependabot-preview[bot]
d530f72075
Bump github.com/digitalocean/godo from 1.48.0 to 1.52.0 (#1019)
Bumps [github.com/digitalocean/godo](https://github.com/digitalocean/godo) from 1.48.0 to 1.52.0.
- [Release notes](https://github.com/digitalocean/godo/releases)
- [Changelog](https://github.com/digitalocean/godo/blob/main/CHANGELOG.md)
- [Commits](https://github.com/digitalocean/godo/compare/v1.48.0...v1.52.0)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>

Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>
2020-11-08 16:17:01 -08:00
Toon Schoenmakers
f58e244cf6
Handle errors from the grafana api by displaying the error message (#1015) 2020-10-29 09:33:55 -07:00
Chris Cummer
bd01083ad6 Add @YuviGold as a contributor 2020-10-24 13:55:47 -07:00
Chris Cummer
7bb6aead0e Exit message call out in readme
Signed-off-by: Chris Cummer <chriscummer@me.com>
2020-10-23 01:31:52 -07:00
Chris Cummer
52b5ac4f0c
Update CHANGELOG.md 2020-10-22 09:30:09 -07:00
Chris Cummer
546f73d56c Merge branch 'grafana' of github.com:schoentoon/wtf into schoentoon-grafana 2020-10-22 09:27:22 -07:00
Chris Cummer
03b6ad6f08
Update CHANGELOG.md 2020-10-21 21:04:42 -07:00
Chris Cummer
47da77a382 Add @applegreengrape as a contributor 2020-10-21 21:03:01 -07:00
Chris Cummer
1dbc28618d Merge branch 'finnhub_mod_for_stocks' of github.com:applegreengrape/wtf into applegreengrape-finnhub_mod_for_stocks 2020-10-21 21:00:18 -07:00
Chris Cummer
0f0b28bdf6 go mod tidy
Signed-off-by: Chris Cummer <chriscummer@me.com>
2020-10-21 04:14:28 -07:00
Chris Cummer
57a965b0d6
Update CHANGELOG.md 2020-10-21 04:10:03 -07:00
dependabot-preview[bot]
f6eac2d7bc
Bump github.com/xanzy/go-gitlab from 0.38.1 to 0.38.2 (#1007)
Bumps [github.com/xanzy/go-gitlab](https://github.com/xanzy/go-gitlab) from 0.38.1 to 0.38.2.
- [Release notes](https://github.com/xanzy/go-gitlab/releases)
- [Changelog](https://github.com/xanzy/go-gitlab/blob/master/CHANGELOG.md)
- [Commits](https://github.com/xanzy/go-gitlab/compare/v0.38.1...v0.38.2)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>

Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>
2020-10-21 04:09:45 -07:00
Chris Cummer
944db701e4
Update CHANGELOG.md 2020-10-21 04:09:27 -07:00
dependabot-preview[bot]
f31168c4fd
Bump github.com/digitalocean/godo from 1.46.0 to 1.48.0 (#1005)
Bumps [github.com/digitalocean/godo](https://github.com/digitalocean/godo) from 1.46.0 to 1.48.0.
- [Release notes](https://github.com/digitalocean/godo/releases)
- [Changelog](https://github.com/digitalocean/godo/blob/main/CHANGELOG.md)
- [Commits](https://github.com/digitalocean/godo/compare/v1.46.0...v1.48.0)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>

Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>
2020-10-21 04:09:01 -07:00
Jade
fd8298dfd1 go lint fix 2020-10-19 20:59:26 +01:00
Jade
a728d448cb update the views 2020-10-19 20:51:39 +01:00
Toon Schoenmakers
441e82a3bd Added grafana alerts widget 2020-10-19 19:03:15 +02:00
Jade
64fa5acccb gofmt 2020-10-19 01:18:40 +01:00
Jade
d152a8beee fix go lint 2020-10-19 01:07:04 +01:00
Jade
5c6833a0df add the module to the widget_maker.go 2020-10-19 00:42:03 +01:00
Jade
1ff75dd4cf update 2020-10-19 00:15:29 +01:00
Jade
4d3e9506e4 added finnhub mod 2020-10-19 00:03:07 +01:00
Jade
63462ac8ef add finnhub modules 2020-10-16 23:18:02 +01:00
Chris Cummer
cff8e7fae7 Add @sahilister as a contributor 2020-10-14 16:43:55 -07:00
Chris Cummer
c10e67d4b5
Update CHANGELOG.md 2020-10-14 12:32:43 -07:00
Chris Cummer
e5f52587da Merge branch 'dependabot/go_modules/google.golang.org/api-0.33.0' 2020-10-14 12:31:25 -07:00
Chris Cummer
35e5344e5c Upate and fix naming module circular load loop
Signed-off-by: Chris Cummer <chriscummer@me.com>
2020-10-14 12:31:07 -07:00
Chris Cummer
a746ab6975 Remove unnecessary parameter passing in WtfApp
Signed-off-by: Chris Cummer <chriscummer@me.com>
2020-10-14 12:16:48 -07:00
Chris Cummer
63aa353db3
Update CHANGELOG.md 2020-10-14 09:39:11 -07:00
Chris Cummer
f84142553c
WTF-986 User-definable DigitalOcean columns (#1001)
* WTF-986 Wrap the DigitalOcean droplet in our own droplet

This gives us something to build off while still providing the
underlying functionality of the original droplet instance.

Signed-off-by: Chris Cummer <chriscummer@me.com>

* WTF-986 Dynamically display droplet attributes based on defined column names

Signed-off-by: Chris Cummer <chriscummer@me.com>

* WTF-986 Read DigitalOcean column configuration from settings

Signed-off-by: Chris Cummer <chriscummer@me.com>

* WTF-986 Extract the reflection bits into a Reflective package

Signed-off-by: Chris Cummer <chriscummer@me.com>
2020-10-14 09:29:58 -07:00
dependabot-preview[bot]
b18c838a69
Bump google.golang.org/api from 0.30.0 to 0.33.0
Bumps [google.golang.org/api](https://github.com/googleapis/google-api-go-client) from 0.30.0 to 0.33.0.
- [Release notes](https://github.com/googleapis/google-api-go-client/releases)
- [Changelog](https://github.com/googleapis/google-api-go-client/blob/master/CHANGES.md)
- [Commits](https://github.com/googleapis/google-api-go-client/compare/v0.30.0...v0.33.0)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-10-14 05:50:57 +00:00
Chris Cummer
b2e0c520e8
Update CHANGELOG.md 2020-10-13 09:45:57 -07:00
Chris Cummer
b333a1499a Update CHANGELOG.md
Signed-off-by: Chris Cummer <chriscummer@me.com>
2020-10-13 09:40:27 -07:00
Jason Schweier
0ab72ab7bb
Default domain for gitlab (#1000)
* Add a default domain for gitlab

* Remove trailing whitespace
2020-10-13 09:39:05 -07:00
Chris Cummer
ebea03edcf
Update README.md
Note that WTF now requires Go 1.15 due to how we import `time/tzinfo` now.
2020-10-12 13:16:44 -07:00
Chris Cummer
35499987ce
Move loading of the GitHub user into startup (#999)
Having the calls on exit delayed the exiting of the app
by a second or more, which was noticable and annoying.

This change loads the GitHub user data asynchronously while the
app is running, removing the delay on exit.

Signed-off-by: Chris Cummer <chriscummer@me.com>
2020-10-12 12:23:39 -07:00
Chris Cummer
1afaa2ba45 Clean up the openFileUtil code in main
Signed-off-by: Chris Cummer <chriscummer@me.com>
2020-10-11 20:37:04 -07:00
Chris Cummer
9fc8eccba9
Update CHANGELOG.md 2020-10-11 20:15:20 -07:00
Chris Cummer
1b261acb5c Add @franga2000 as a contributor 2020-10-11 20:13:42 -07:00
Chris Cummer
dc6d9d4e12 Merge branch 'franga2000-feature/uptimerobot' 2020-10-11 20:11:15 -07:00
Chris Cummer
21bdf18e98 Remove a redundant byte conversion
Signed-off-by: Chris Cummer <chriscummer@me.com>
2020-10-11 20:10:57 -07:00
Miha Frangež
b8c9f96db2 UptimeRobot: option to show offline monitors first 2020-10-11 20:09:18 -07:00
Miha Frangež
dd4899a07c UptimeRobot: improve uptime formatting 2020-10-11 20:09:18 -07:00
Miha Frangež
6908e744e1 Make CI happy 2020-10-11 20:09:18 -07:00
Miha Frangež
7f05fbcda5 Implemented UptimeRobot widget
This is the first working version of the UptimeRobot module, as discussed in #979
2020-10-11 20:09:18 -07:00
Chris Cummer
33bb990583
Update CHANGELOG.md 2020-10-11 18:18:47 -07:00
Chris Cummer
9f94e8c63a Add an app exit banner message 2020-10-11 16:55:16 -07:00
Chris Cummer
84763f3947
Update CHANGELOG.md 2020-10-11 16:49:06 -07:00
Chris Cummer
36c4a7f428 Fix merge conflict in main.go
Signed-off-by: Chris Cummer <chriscummer@me.com>
2020-10-11 16:39:47 -07:00
Todd Trimble
65a9894bba Explain time/tzdata import with comment 2020-10-11 19:35:31 -04:00
Todd Trimble
98f3e33f8d Merge remote-tracking branch 'upstream/master' into master 2020-10-11 19:21:17 -04:00
Todd Trimble
0e4f5e8bf8 Blank import tzdata to fix bug on Windows host 2020-10-11 16:20:37 -07:00
Chris Cummer
b527d9c4da
Update golang-github-actions to use go 1.15.2 (#998)
Signed-off-by: Chris Cummer <chriscummer@me.com>
2020-10-11 16:18:19 -07:00
Todd Trimble
f2fa715bb5 Merge remote-tracking branch 'upstream/master' into master 2020-10-11 13:07:04 -04:00
Todd Trimble
3ea1d4542a Blank import tzdata to fix bug on Windows host 2020-10-11 13:05:45 -04:00
Chris Cummer
6593827a99 Merge branch 'jmks-improve-test-coverage' 2020-10-09 09:36:00 -07:00
Chris Cummer
470a1deb22 go mod tidy
Signed-off-by: Chris Cummer <chriscummer@me.com>
2020-10-09 09:34:50 -07:00
Jason Schweier
9a2bd261c0 Test Validate func 2020-10-08 20:29:50 -04:00
Jason Schweier
4205327b95 Test NewModuleValidator func 2020-10-08 20:29:50 -04:00
Jason Schweier
b1022d6d18 Fix typo 2020-10-08 20:29:50 -04:00
Chris Cummer
3c53af8c24 Merge branch 'Seanstoppable-cmdrunnertty' 2020-10-08 12:29:48 -07:00
Chris Cummer
4064d42fed Fix go.mod conflict
Signed-off-by: Chris Cummer <chriscummer@me.com>
2020-10-08 12:29:32 -07:00
Sean Smith
cb29f8126c Downgrade tview 2020-10-08 14:54:25 -04:00
Chris Cummer
7ce124aaab
Update CHANGELOG.md 2020-10-08 11:47:44 -07:00
Chris Cummer
a7334b0c58 Merge branch 'dependabot/go_modules/github.com/shirou/gopsutil-2.20.9incompatible' 2020-10-08 11:47:03 -07:00
Chris Cummer
05b9d8adca go mod tidy
Signed-off-by: Chris Cummer <chriscummer@me.com>
2020-10-08 11:46:37 -07:00
Chris Cummer
b96d319b26 Merge branch 'master' into dependabot/go_modules/github.com/shirou/gopsutil-2.20.9incompatible 2020-10-08 11:46:23 -07:00
Chris Cummer
89edac3e8f Merge branch 'dependabot/go_modules/github.com/nicklaw5/helix-0.7.0' 2020-10-08 11:45:19 -07:00
Chris Cummer
8d517eeb5e go mod tidy
Signed-off-by: Chris Cummer <chriscummer@me.com>
2020-10-08 11:44:34 -07:00
Chris Cummer
589af9917a Merge branch 'master' into dependabot/go_modules/github.com/nicklaw5/helix-0.7.0 2020-10-08 11:44:10 -07:00
Chris Cummer
a43b302452 Merge branch 'dependabot/go_modules/github.com/digitalocean/godo-1.46.0' 2020-10-08 11:43:33 -07:00
Chris Cummer
534514f558 go mod tidy
Signed-off-by: Chris Cummer <chriscummer@me.com>
2020-10-08 11:42:45 -07:00
Chris Cummer
2990ff4ac0 Merge branch 'master' into dependabot/go_modules/github.com/digitalocean/godo-1.46.0 2020-10-08 11:42:05 -07:00
Sean Smith
7643109c63 Fix unlocking bug noticed during refactor 2020-10-08 08:17:52 -04:00
Todd Trimble
2f70693656
Correct minor typo in clock settings help text (#993) 2020-10-07 22:11:39 -07:00
Sean Smith
e23cec2897 Let pty be optional 2020-10-07 19:40:26 -04:00
Sean Smith
34154620f6 Handle error handling better
Don't panic
Add function due to reuse
Catch all errors to appease CI
2020-10-07 19:40:26 -04:00
Sean Smith
57bf5c7417 Have cmdrunner use a tty
This lets us get proper coloring
Fixes #577
2020-10-07 19:40:26 -04:00
Sean Smith
c6567d15af
Upgrade travis to 1.15.x (#991)
Missed item from previous upgrade
2020-10-07 19:39:56 -04:00
Chris Cummer
450483791f Obey the linter; make the linter happy
Signed-off-by: Chris Cummer <chriscummer@me.com>
2020-10-07 16:06:57 -07:00
Sean Smith
3c63eee8d3
Create generalized todo module (#982)
* Create generalized todo module

Makes existing modules "backends"
This gives us a consistent interface

* Fix check issues

* Fix lint errors

* Make changes to stay on wtfutil todoist fork
2020-10-07 14:58:24 -07:00
Todd Trimble
38e21605a4
Add tests for specified min column width (#990) 2020-10-07 14:56:20 -07:00
Chris Cummer
87ce0d887e Pretty format the GitHub stats
Signed-off-by: Chris Cummer <chriscummer@me.com>
2020-10-06 20:05:19 -07:00
Chris Cummer
f7d99c5eff Don't trim whitespace from beginning of widget
Some widgets format the output using whitespace padding
at the beginning.

Signed-off-by: Chris Cummer <chriscummer@me.com>
2020-10-06 20:00:50 -07:00
Chris Cummer
0f07cb6980 Add @mhanberg as a contributor 2020-10-06 19:46:49 -07:00
Chris Cummer
264b9875ea Add @trimble as a contributor 2020-10-06 19:42:28 -07:00
Todd Trimble
4192a02594
Add info table tests (#985)
* Add info table tests

* Fix lint error about initialization
2020-10-06 19:41:44 -07:00
Chris Cummer
798d812f80
Update CHANGELOG.md 2020-10-06 19:38:38 -07:00
Chris Cummer
1712034a14 Merge branch 'Seanstoppable-naturalclockorder' 2020-10-06 19:34:34 -07:00
Chris Cummer
15b91b2d28 Merge branch 'naturalclockorder' of github.com:Seanstoppable/wtf into Seanstoppable-naturalclockorder 2020-10-06 19:31:05 -07:00
dependabot-preview[bot]
b8168ce7f2
Bump github.com/digitalocean/godo from 1.44.0 to 1.46.0
Bumps [github.com/digitalocean/godo](https://github.com/digitalocean/godo) from 1.44.0 to 1.46.0.
- [Release notes](https://github.com/digitalocean/godo/releases)
- [Changelog](https://github.com/digitalocean/godo/blob/main/CHANGELOG.md)
- [Commits](https://github.com/digitalocean/godo/compare/v1.44.0...v1.46.0)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-10-06 05:49:32 +00:00
Chris Cummer
f1b31f6f49
Update CHANGELOG.md 2020-10-04 10:35:16 -07:00
Chris Cummer
293ee105f7 Merge branch 'cyingfan-master' 2020-10-04 10:34:05 -07:00
Chris Cummer
a6da089bec Merge branch 'master' of github.com:cyingfan/wtf into cyingfan-master 2020-10-04 10:33:09 -07:00
Ying Fan Chong
2537a7f49a Fix config file path 2020-10-04 20:53:27 +08:00
Sean Smith
fcc2a211df Add natural ordering for clocks
This turns locations into an ordered array, so we can have a 'natural' ordering
This is backwards compatible
Resolves #896
2020-10-03 13:10:50 -04:00
Chris Cummer
f2517b3e64
Update CHANGELOG.md 2020-10-03 09:26:34 -07:00
Sean Smith
cab3f9c658
Upgrade to golang 1.15 (#980) 2020-10-03 09:24:41 -07:00
Chris Cummer
6cc00f54d3 Merge branch 'master' of github.com:wtfutil/wtf 2020-10-03 06:05:56 -07:00
Chris Cummer
04f62d3de8 Add @jamietanna as a contributor 2020-10-03 06:05:50 -07:00
Chris Cummer
c9d65fd7e7 Add @MartinJohns as a contributor 2020-10-03 06:05:15 -07:00
Jamie Tanna
aa8ed14a1b
Document how to install on Arch (#978) 2020-10-03 06:04:46 -07:00
Chris Cummer
2b10f8de88
Update CHANGELOG.md 2020-10-03 06:01:23 -07:00
Chris Cummer
c1f7e3acc9 Merge branch 'cyingfan-master' 2020-10-03 05:58:44 -07:00
Ying Fan Chong
0f36063696 Prevent extra empty line in highlightable text 2020-10-02 20:53:33 +08:00
Ying Fan Chong
9a366ffeb9 Fix sorting for feed without published date 2020-10-02 20:35:20 +08:00
Chris Cummer
772bea0152
Update CHANGELOG.md 2020-10-02 04:12:47 -07:00
Chris Cummer
edf0aa5c14 Add @cyingfan as a contributor 2020-10-02 04:11:04 -07:00
Chris Cummer
d46546a86b Merge branch 'cyingfan-master' 2020-10-02 04:09:59 -07:00
Ying Fan Chong
bdf642b773 Fix help text 2020-10-01 22:24:33 +08:00
Ying Fan Chong
184b3744c2 Apply gofmt 2020-10-01 22:16:19 +08:00
Ying Fan Chong
c4ca3d9b2a Add capability to switch content between title, link and title+content 2020-10-01 22:12:31 +08:00
dependabot-preview[bot]
c8562c533b
Bump github.com/shirou/gopsutil
Bumps [github.com/shirou/gopsutil](https://github.com/shirou/gopsutil) from 2.20.8+incompatible to 2.20.9+incompatible.
- [Release notes](https://github.com/shirou/gopsutil/releases)
- [Commits](https://github.com/shirou/gopsutil/compare/v2.20.8...v2.20.9)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-10-01 05:53:57 +00:00
Chris Cummer
e56b8693a2
Update CHANGELOG.md 2020-09-29 10:10:37 -07:00
Chris Cummer
5e44a01699 Sort exchange rates alphabetically and group same base rates by row color
Before this, exchange rates were read from a map, which meant the
display order was random.

This ensures that the list of exchange rates displays in a consistent
order and visually denotes rates for the same currency.

Signed-off-by: Chris Cummer <chriscummer@me.com>
2020-09-29 10:06:46 -07:00
Chris Cummer
787d27b498 go mod tidy
Signed-off-by: Chris Cummer <chriscummer@me.com>
2020-09-25 06:58:09 -07:00
dependabot-preview[bot]
71a308b87f
Bump github.com/alecthomas/chroma from 0.8.0 to 0.8.1 (#971)
Bumps [github.com/alecthomas/chroma](https://github.com/alecthomas/chroma) from 0.8.0 to 0.8.1.
- [Release notes](https://github.com/alecthomas/chroma/releases)
- [Changelog](https://github.com/alecthomas/chroma/blob/master/.goreleaser.yml)
- [Commits](https://github.com/alecthomas/chroma/compare/v0.8.0...v0.8.1)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>

Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>
Co-authored-by: Chris Cummer <chriscummer@me.com>
2020-09-25 06:57:56 -07:00
Chris Cummer
4a14acd89c go mod tidy
Signed-off-by: Chris Cummer <chriscummer@me.com>
2020-09-25 06:56:42 -07:00
dependabot-preview[bot]
e38ade946a
Bump github.com/nicklaw5/helix from 0.5.9 to 0.7.0
Bumps [github.com/nicklaw5/helix](https://github.com/nicklaw5/helix) from 0.5.9 to 0.7.0.
- [Release notes](https://github.com/nicklaw5/helix/releases)
- [Commits](https://github.com/nicklaw5/helix/compare/v0.5.9...v0.7.0)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-09-25 13:56:16 +00:00
Chris Cummer
585f6cc64c
Update CHANGELOG.md 2020-09-25 06:55:58 -07:00
Chris Cummer
10ff19ff24 Merge branch 'master' of github.com:wtfutil/wtf 2020-09-25 06:54:56 -07:00
Chris Cummer
904df45548 go mod tidy
Signed-off-by: Chris Cummer <chriscummer@me.com>
2020-09-25 06:54:53 -07:00
dependabot-preview[bot]
6a5f4ba54d
Bump github.com/adlio/trello from 1.7.0 to 1.8.0 (#970)
Bumps [github.com/adlio/trello](https://github.com/adlio/trello) from 1.7.0 to 1.8.0.
- [Release notes](https://github.com/adlio/trello/releases)
- [Commits](https://github.com/adlio/trello/compare/v1.7.0...v1.8.0)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>

Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>
2020-09-25 06:54:18 -07:00
Chris Cummer
dae9135e1d
Revert "Bump google.golang.org/api from 0.30.0 to 0.32.0 (#968)" (#972)
This reverts commit 48dda57473d4532c34a5bc0b765c74f20fc91ae4.
2020-09-25 06:53:21 -07:00
dependabot-preview[bot]
caa721d6e1
Bump github.com/xanzy/go-gitlab from 0.33.0 to 0.38.1 (#969)
Bumps [github.com/xanzy/go-gitlab](https://github.com/xanzy/go-gitlab) from 0.33.0 to 0.38.1.
- [Release notes](https://github.com/xanzy/go-gitlab/releases)
- [Changelog](https://github.com/xanzy/go-gitlab/blob/master/CHANGELOG.md)
- [Commits](https://github.com/xanzy/go-gitlab/compare/v0.33.0...v0.38.1)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>

Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>
2020-09-25 06:51:44 -07:00
dependabot-preview[bot]
48dda57473
Bump google.golang.org/api from 0.30.0 to 0.32.0 (#968)
Bumps [google.golang.org/api](https://github.com/googleapis/google-api-go-client) from 0.30.0 to 0.32.0.
- [Release notes](https://github.com/googleapis/google-api-go-client/releases)
- [Changelog](https://github.com/googleapis/google-api-go-client/blob/master/CHANGES.md)
- [Commits](https://github.com/googleapis/google-api-go-client/compare/v0.30.0...v0.32.0)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>

Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>
2020-09-25 06:50:29 -07:00
Chris Cummer
30b0d8a981
Update CHANGELOG.md 2020-09-25 06:49:56 -07:00
dependabot-preview[bot]
9fb90c02f0
Bump github.com/digitalocean/godo from 1.42.1 to 1.44.0 (#967)
Bumps [github.com/digitalocean/godo](https://github.com/digitalocean/godo) from 1.42.1 to 1.44.0.
- [Release notes](https://github.com/digitalocean/godo/releases)
- [Changelog](https://github.com/digitalocean/godo/blob/main/CHANGELOG.md)
- [Commits](https://github.com/digitalocean/godo/compare/v1.42.1...v1.44.0)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>

Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>
2020-09-25 06:49:46 -07:00
dependabot-preview[bot]
1a596fa635
Bump github.com/mmcdole/gofeed from 1.0.0 to 1.1.0 (#965)
Bumps [github.com/mmcdole/gofeed](https://github.com/mmcdole/gofeed) from 1.0.0 to 1.1.0.
- [Release notes](https://github.com/mmcdole/gofeed/releases)
- [Commits](https://github.com/mmcdole/gofeed/compare/v1.0.0...v1.1.0)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>

Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>
2020-09-25 06:48:50 -07:00
Chris Cummer
d672f57c14 Fix warning with type conversion from rune + int to string
Signed-off-by: Chris Cummer <chriscummer@me.com>
2020-09-25 06:47:28 -07:00
dependabot-preview[bot]
cae3ae7c4b
Bump github.com/shirou/gopsutil (#962)
Bumps [github.com/shirou/gopsutil](https://github.com/shirou/gopsutil) from 2.20.7+incompatible to 2.20.8+incompatible.
- [Release notes](https://github.com/shirou/gopsutil/releases)
- [Commits](https://github.com/shirou/gopsutil/compare/v2.20.7...v2.20.8)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>

Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>
2020-09-25 06:18:39 -07:00
dependabot-preview[bot]
17dc53256a
Bump github.com/gdamore/tcell from 1.3.0 to 1.4.0 (#960)
Bumps [github.com/gdamore/tcell](https://github.com/gdamore/tcell) from 1.3.0 to 1.4.0.
- [Release notes](https://github.com/gdamore/tcell/releases)
- [Commits](https://github.com/gdamore/tcell/compare/v1.3.0...v1.4.0)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>

Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>
2020-09-25 06:18:03 -07:00
298 changed files with 5749 additions and 2077 deletions

View File

@ -959,6 +959,125 @@
"name": "Tim Hwang",
"avatar_url": "https://avatars3.githubusercontent.com/u/5831434?v=4",
"profile": "http://timhwang21.gitbook.io",
"contributions": []
},
{
"login": "cyingfan",
"name": "Ying Fan Chong",
"avatar_url": "https://avatars1.githubusercontent.com/u/10404961?v=4",
"profile": "http://about.me/yingfan",
"contributions": []
},
{
"login": "MartinJohns",
"name": "Martin Johns",
"avatar_url": "https://avatars1.githubusercontent.com/u/5269069?v=4",
"profile": "https://github.com/MartinJohns",
"contributions": []
},
{
"login": "jamietanna",
"name": "Jamie Tanna",
"avatar_url": "https://avatars0.githubusercontent.com/u/3315059?v=4",
"profile": "https://www.jvt.me",
"contributions": []
},
{
"login": "trimble",
"name": "Todd Trimble",
"avatar_url": "https://avatars3.githubusercontent.com/u/371317?v=4",
"profile": "https://github.com/trimble",
"contributions": []
},
{
"login": "mhanberg",
"name": "Mitchell Hanberg",
"avatar_url": "https://avatars2.githubusercontent.com/u/5523984?v=4",
"profile": "https://www.mitchellhanberg.com",
"contributions": []
},
{
"login": "franga2000",
"name": "Miha Frangež",
"avatar_url": "https://avatars3.githubusercontent.com/u/3891092?v=4",
"profile": "https://franga2000.com",
"contributions": []
},
{
"login": "sahilister",
"name": "Sahil Dhiman",
"avatar_url": "https://avatars0.githubusercontent.com/u/52946452?v=4",
"profile": "https://blog.sahilister.in/",
"contributions": []
},
{
"login": "applegreengrape",
"name": "Pingzhou | 平舟",
"avatar_url": "https://avatars2.githubusercontent.com/u/17727004?v=4",
"profile": "https://pzoo.netlify.app/",
"contributions": []
},
{
"login": "YuviGold",
"name": "Yuval Goldberg",
"avatar_url": "https://avatars0.githubusercontent.com/u/29873449?v=4",
"profile": "https://github.com/YuviGold",
"contributions": []
},
{
"login": "dabcoder",
"name": "David Bouchare",
"avatar_url": "https://avatars3.githubusercontent.com/u/5034531?v=4",
"profile": "https://github.com/dabcoder",
"contributions": []
},
{
"login": "stone",
"name": "Fredrik Steen",
"avatar_url": "https://avatars3.githubusercontent.com/u/29077?v=4",
"profile": "https://github.com/stone",
"contributions": []
},
{
"login": "zye1996",
"name": "zye1996",
"avatar_url": "https://avatars2.githubusercontent.com/u/28901953?v=4",
"profile": "https://github.com/zye1996",
"contributions": []
},
{
"login": "pgaxatte",
"name": "Pierre Gaxatte",
"avatar_url": "https://avatars.githubusercontent.com/u/30696904?v=4",
"profile": "https://github.com/pgaxatte",
"contributions": []
},
{
"login": "xntrik",
"name": "Christian Frichot",
"avatar_url": "https://avatars.githubusercontent.com/u/678260?v=4",
"profile": "https://xntrik.wtf",
"contributions": []
},
{
"login": "LKaemmerling",
"name": "Lukas Kämmerling",
"avatar_url": "https://avatars.githubusercontent.com/u/4281581?v=4",
"profile": "https://lukas-kaemmerling.de",
"contributions": []
},
{
"login": "inetAnt",
"name": "Antoine Meillet",
"avatar_url": "https://avatars.githubusercontent.com/u/1765366?v=4",
"profile": "https://inetant.net/",
"contributions": []
},
{
"login": "cclauss",
"name": "Christian Clauss",
"avatar_url": "https://avatars.githubusercontent.com/u/3709715?v=4",
"profile": "https://www.patreon.com/cclauss",
"contributions": [
]
}

11
.github/dependabot.yml vendored Normal file
View File

@ -0,0 +1,11 @@
version: 2
updates:
- package-ecosystem: gomod
directory: "/"
schedule:
interval: daily
open-pull-requests-limit: 10
reviewers:
- senorprogrammer
assignees:
- senorprogrammer

View File

@ -13,8 +13,10 @@ jobs:
steps:
- uses: actions/checkout@v2
- name: golangci-lint
uses: golangci/golangci-lint-action@v1
uses: golangci/golangci-lint-action@v2
with:
# Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version.
version: v1.26
# Required: the version of golangci-lint is required and must be
# specified without patch version: we always use the latest patch version.
# https://github.com/golangci/golangci-lint/releases
version: v1.39
args: ./...

30
.github/workflows/goreleaser.yml vendored Normal file
View File

@ -0,0 +1,30 @@
name: goreleaser
on:
push:
tags:
- '*'
jobs:
goreleaser:
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
-
name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.16
-
name: Run GoReleaser
uses: goreleaser/goreleaser-action@v2
with:
version: latest
args: release --rm-dist
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GH_PAT }}

View File

@ -8,7 +8,7 @@ jobs:
steps:
- uses: actions/checkout@master
- name: check
uses: grandcolline/golang-github-actions@v1.1.0
uses: grandcolline/golang-github-actions@4356d0458ea4bfdb55fcb296437812acef970f9b
with:
run: imports
token: ${{ secrets.GITHUB_TOKEN }}
@ -19,7 +19,7 @@ jobs:
steps:
- uses: actions/checkout@master
- name: check
uses: grandcolline/golang-github-actions@v1.1.0
uses: grandcolline/golang-github-actions@4356d0458ea4bfdb55fcb296437812acef970f9b
with:
run: errcheck
token: ${{ secrets.GITHUB_TOKEN }}
@ -30,7 +30,7 @@ jobs:
#steps:
#- uses: actions/checkout@master
#- name: check
#uses: grandcolline/golang-github-actions@v1.1.0
#uses: grandcolline/golang-github-actions@4356d04
#with:
#run: lint
#token: ${{ secrets.GITHUB_TOKEN }}
@ -41,7 +41,7 @@ jobs:
steps:
- uses: actions/checkout@master
- name: check
uses: grandcolline/golang-github-actions@v1.1.0
uses: grandcolline/golang-github-actions@4356d0458ea4bfdb55fcb296437812acef970f9b
with:
run: shadow
token: ${{ secrets.GITHUB_TOKEN }}
@ -52,7 +52,7 @@ jobs:
steps:
- uses: actions/checkout@master
- name: check
uses: grandcolline/golang-github-actions@v1.1.0
uses: grandcolline/golang-github-actions@4356d0458ea4bfdb55fcb296437812acef970f9b
with:
run: staticcheck
token: ${{ secrets.GITHUB_TOKEN }}
@ -63,7 +63,7 @@ jobs:
#steps:
#- uses: actions/checkout@master
#- name: check
#uses: grandcolline/golang-github-actions@v1.1.0
#uses: grandcolline/golang-github-actions@4356d04
#with:
#run: sec
#token: ${{ secrets.GITHUB_TOKEN }}

View File

@ -1,3 +1,6 @@
run:
timeout: 2m
linters:
enable:
- vet

View File

@ -21,10 +21,10 @@ before:
- make install
brews:
- github:
owner: wtfutil
name: homebrew-wtfutil
-
name: wtfutil
homepage: 'https://wtfutil.com'
description: 'The personal information dashboard for your terminal.'
tap:
owner: wtfutil
name: homebrew-wtfutil

View File

@ -1,7 +1,7 @@
language: go
go:
- "1.14.x"
- "1.16.x"
before_install:
# Make sure travis builds work for forks

View File

@ -4,6 +4,94 @@
### ⚡️ Added
* Yahoo Finance module added, by [@inetAnt](https://github.com/inetAnt)
### 🐞 Fixed
* Fixed error closing the Jira module response body, [#1070](https://github.com/wtfutil/wtf/issues/1070) by [@senorprogrammer](https://github.com/senorprogrammer)
## v0.36.0
### ⚡️ Added
* HealthChecks module added, by [@stone](https://github.com/stone)
* Asana module added, by [@xntrik](https://github.com/xntrik)
* Kubernetes module now displays the Ready Replicas and Total Replicas count, by [@LKaemmerling](https://github.com/LKaemmerling)
* Now builds using Go 1.16, which provides support for Apple's M1 ARM hardware, by [@LKaemmerling](https://github.com/LKaemmerling)
### 🐞 Fixed
* Numerous dangling response bodies closed, by [@dabcoder](https://github.com/dabcoder)
* HackerNews read-on-response error fixed, by [@LKaemmerling](https://github.com/LKaemmerling)
* CircleCI read-on-response error fixed, by [@dabcoder](https://github.com/dabcoder)
## v0.35.0
### ⚡️ Added
* CircleCI module now supports `numberOfBuilds` setting defining how many builds to display, [#1020](https://github.com/wtfutil/wtf/issues/1020) by [@dabcoder](https://github.com/dabcoder)
* The <kbd>\\</kbd> key now opens module documentation in the browser for the currently-focused module, by [@senorprogrammer](https://github.com/senorprogrammer)
* Krisinformation module added, by [@stone](https://github.com/stone)
* Covid module has been added, by [@dabcoder](https://github.com/dabcoder)
* Support for a "Language" configuration key added. Supports any BCP 47 tag for identifying a langauge, by [@senorprogrammer](https://github.com/senorprogrammer)
### 🐞 Fixed
* CryptoLive prices update again, [#1041](https://github.com/wtfutil/wtf/issues/1041) by [@zye1996](https://github.com/zye1996)
## v0.34.0
2020-11-08
### ⚡️ Added
* DigitalOcean module now supports custom column definitions in the default layout. See [the docs](https://wtfutil.com/modules/digitalocean/) for details, [#986](https://github.com/wtfutil/wtf/issues/986) by [@senorprogrammer](https://github.com/senorprogrammer)
* Finnhub stock quotes module added, [#930](https://github.com/wtfutil/wtf/issues/930) by [@applegreengrape](https://github.com/applegreengrape)
* Grafana Alerts module added, by [@schoentoon](https://github.com/schoentoon)
### 👍 Updated
* Updated `google.golang.org/api` from 0.30.0 to 0.33.0
* Updated `github.com/digitalocean/godo` from 1.46.0 to 1.52.0
* Updated `github.com/xanzy/go-gitlab` from 0.38.1 to 0.39.0
* Updated `github.com/zorkian/go-datadog-api` from 2.29.0+incompatible to 2.30.0+incompatible
* Updated `golang.org/x/text` from 0.3.3 to 0.3.4
## v0.33.0
2020-10-13
### ⚡️ Added
* FeedReader module supports [display mode switching](https://github.com/wtfutil/wtf/pull/976) via the `t` key, by [@cyingfan](https://github.com/cyingfan)
* Clocks module now supports `natural` ordering option, [#896](https://github.com/wtfutil/wtf/issues/896) by [@seanstoppable](https://github.com/Seanstoppable)
* Exit banner message added, by [@senorprogrammer](https://github.com/senorprogrammer)
* [UptimeRobot module added](https://github.com/wtfutil/wtf/pull/983), by [@franga2000](https://github.com/franga2000)
* Gitlab module now defaults the domain to `https://gitlab.com`, by [@jmks](https://github.com/jmks)
### 🐞 Fixed
* Exchange Rates module now displays rates in alphabetical order, sorted by the base rate, by [@senorprogrammer](https://github.com/senorprogrammer)
* Feed Reader module no longer crashes on feeds that don't have a published date, [#958](https://github.com/wtfutil/wtf/issues/958) by [@cyingfan](https://github.com/cyingfan)
* Stray blank lines no longer appear at the end of highlightable lists, [#977](https://github.com/wtfutil/wtf/pull/977) by [@cyingfan](https://github.com/cyingfan)
* `config.yml` now properly set to `0600` instead of `0666`, by [@cyingfan](https://github.com/cyingfan)
* Now blank-imports the `time/tzinfo` package to provide timezone support for Windows users, [#994](https://github.com/wtfutil/wtf/issues/994) by [@trimble](https://github.com/trimble)
### 👍 Updated
* Updated `github.com/gdamore/tcell` from 1.3.0 to 1.4.0
* Updated `github.com/shirou/gopsutil` from 2.20.7+incompatible to 2.20.9+incompatible
* Updated `github.com/mmcdole/gofeed` from 1.0.0 to 1.1.0
* Updated `github.com/digitalocean/godo` from 1.42.1 to 1.46.0
* Updated `github.com/xanzy/go-gitlab` from 0.33.0 to 0.38.1
* Updated `github.com/adlio/trello` from 1.7.0 to 1.8.0
* Updated `github.com/alecthomas/chroma` from 0.8.0 to 0.8.1
* Updated `github.com/nicklaw5/helix` from 0.5.9 to 0.7.0
* Now requires Go 1.15 for compilation in Dockerfiles and go.mod, by [@seanstoppable](https://github.com/Seanstoppable)
## v0.32.0
### ⚡️ Added
* PagerDuty module now supports `showOncallEnd` setting, which determines whether or not to display the oncall rotation end date, by [@senorprogrammer](https://github.com/senorprogrammer)
* Exchange Rates module now supports `precision` setting, which determines how many decimal places to display, [#897](https://github.com/wtfutil/wtf/issues/897) by [@senorprogrammer](https://github.com/senorprogrammer)

View File

@ -1,4 +1,4 @@
FROM golang:1.13-alpine as build
FROM golang:1.16-alpine as build
ARG version=master

View File

@ -1,4 +1,4 @@
FROM golang:1.13 as build
FROM golang:1.16 as build
ARG version=master

View File

@ -1,6 +1,8 @@
Copyright 2018, Chris Cummer
*Mozilla Public License, version 2.0*
Mozilla Public License, version 2.0 1. Definitions 1.1. “Contributor” means each individual or legal entity that creates, contributes to the creation of, or owns Covered Software.
1. Definitions
1.1. “Contributor” means each individual or legal entity that creates, contributes to the creation of, or owns Covered Software.
1.2. “Contributor Version” means the combination of the Contributions of others (if any) used by a Contributor and that particular Contributors Contribution.
@ -24,9 +26,9 @@ that the Covered Software was made available under the terms of version 1.1 or e
1.10. “Modifications” means any of the following:
any file in Source Code Form that results from an addition to, deletion from, or modification of the contents of Covered Software; or
any file in Source Code Form that results from an addition to, deletion from, or modification of the contents of Covered Software; or
any new file in Source Code Form that contains any Covered Software.
any new file in Source Code Form that contains any Covered Software.
1.11. “Patent Claims” of a Contributor means any patent claim(s), including without limitation, method, process, and apparatus claims, in any patent Licensable by such Contributor that would be infringed, but for the grant of the License, by the making, using, selling, offering for sale, having made, import, or transfer of either its Contributions or its Contributor Version.
@ -36,7 +38,9 @@ any new file in Source Code Form that contains any Covered Software.
1.14. “You” (or “Your”) means an individual or a legal entity exercising rights under this License. For legal entities, “You” includes any entity that controls, is controlled by, or is under common control with You. For purposes of this definition, “control” means (a) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (b) ownership of more than fifty percent (50%) of the outstanding shares or beneficial ownership of such entity.
2. License Grants and Conditions 2.1. Grants Each Contributor hereby grants You a world-wide, royalty-free, non-exclusive license:
2. License Grants and Conditions
2.1. Grants Each Contributor hereby grants You a world-wide, royalty-free, non-exclusive license:
under intellectual property rights (other than patent or trademark) Licensable by such Contributor to use, reproduce, make available, modify, display, perform, distribute, and otherwise exploit its Contributions, either on an unmodified basis, with Modifications, or as part of a Larger Work; and
@ -62,7 +66,9 @@ This License does not grant any rights in the trademarks, service marks, or logo
2.7. Conditions Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted in Section 2.1.
3. Responsibilities 3.1. Distribution of Source Form All distribution of Covered Software in Source Code Form, including any Modifications that You create or to which You contribute, must be under the terms of this License. You must inform recipients that the Source Code Form of the Covered Software is governed by the terms of this License, and how they can obtain a copy of this License. You may not attempt to alter or restrict the recipients rights in the Source Code Form.
3. Responsibilities
3.1. Distribution of Source Form All distribution of Covered Software in Source Code Form, including any Modifications that You create or to which You contribute, must be under the terms of this License. You must inform recipients that the Source Code Form of the Covered Software is governed by the terms of this License, and how they can obtain a copy of this License. You may not attempt to alter or restrict the recipients rights in the Source Code Form.
3.2. Distribution of Executable Form If You distribute Covered Software in Executable Form then:
@ -76,23 +82,37 @@ You may distribute such Executable Form under the terms of this License, or subl
3.5. Application of Additional Terms You may choose to offer, and to charge a fee for, warranty, support, indemnity or liability obligations to one or more recipients of Covered Software. However, You may do so only on Your own behalf, and not on behalf of any Contributor. You must make it absolutely clear that any such warranty, support, indemnity, or liability obligation is offered by You alone, and You hereby agree to indemnify every Contributor for any liability incurred by such Contributor as a result of warranty, support, indemnity or liability terms You offer. You may include additional disclaimers of warranty and limitations of liability specific to any jurisdiction.
4. Inability to Comply Due to Statute or Regulation If it is impossible for You to comply with any of the terms of this License with respect to some or all of the Covered Software due to statute, judicial order, or regulation then You must: (a) comply with the terms of this License to the maximum extent possible; and (b) describe the limitations and the code they affect. Such description must be placed in a text file included with all distributions of the Covered Software under this License. Except to the extent prohibited by statute or regulation, such description must be sufficiently detailed for a recipient of ordinary skill to be able to understand it.
4. Inability to Comply Due to Statute or Regulation
5. Termination 5.1. The rights granted under this License will terminate automatically if You fail to comply with any of its terms. However, if You become compliant, then the rights granted under this License from a particular Contributor are reinstated (a) provisionally, unless and until such Contributor explicitly and finally terminates Your grants, and (b) on an ongoing basis, if such Contributor fails to notify You of the non-compliance by some reasonable means prior to 60 days after You have come back into compliance. Moreover, Your grants from a particular Contributor are reinstated on an ongoing basis if such Contributor notifies You of the non-compliance by some reasonable means, this is the first time You have received notice of non-compliance with this License from such Contributor, and You become compliant prior to 30 days after Your receipt of the notice.
If it is impossible for You to comply with any of the terms of this License with respect to some or all of the Covered Software due to statute, judicial order, or regulation then You must: (a) comply with the terms of this License to the maximum extent possible; and (b) describe the limitations and the code they affect. Such description must be placed in a text file included with all distributions of the Covered Software under this License. Except to the extent prohibited by statute or regulation, such description must be sufficiently detailed for a recipient of ordinary skill to be able to understand it.
5. Termination
5.1. The rights granted under this License will terminate automatically if You fail to comply with any of its terms. However, if You become compliant, then the rights granted under this License from a particular Contributor are reinstated (a) provisionally, unless and until such Contributor explicitly and finally terminates Your grants, and (b) on an ongoing basis, if such Contributor fails to notify You of the non-compliance by some reasonable means prior to 60 days after You have come back into compliance. Moreover, Your grants from a particular Contributor are reinstated on an ongoing basis if such Contributor notifies You of the non-compliance by some reasonable means, this is the first time You have received notice of non-compliance with this License from such Contributor, and You become compliant prior to 30 days after Your receipt of the notice.
5.2. If You initiate litigation against any entity by asserting a patent infringement claim (excluding declaratory judgment actions, counter-claims, and cross-claims) alleging that a Contributor Version directly or indirectly infringes any patent, then the rights granted to You by any and all Contributors for the Covered Software under Section 2.1 of this License shall terminate.
5.3. In the event of termination under Sections 5.1 or 5.2 above, all end user license agreements (excluding distributors and resellers) which have been validly granted by You or Your distributors under this License prior to termination shall survive termination.
6. Disclaimer of Warranty Covered Software is provided under this License on an “as is” basis, without warranty of any kind, either expressed, implied, or statutory, including, without limitation, warranties that the Covered Software is free of defects, merchantable, fit for a particular purpose or non-infringing. The entire risk as to the quality and performance of the Covered Software is with You. Should any Covered Software prove defective in any respect, You (not any Contributor) assume the cost of any necessary servicing, repair, or correction. This disclaimer of warranty constitutes an essential part of this License. No use of any Covered Software is authorized under this License except under this disclaimer.
6. Disclaimer of Warranty
7. Limitation of Liability Under no circumstances and under no legal theory, whether tort (including negligence), contract, or otherwise, shall any Contributor, or anyone who distributes Covered Software as permitted above, be liable to You for any direct, indirect, special, incidental, or consequential damages of any character including, without limitation, damages for lost profits, loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses, even if such party shall have been informed of the possibility of such damages. This limitation of liability shall not apply to liability for death or personal injury resulting from such partys negligence to the extent applicable law prohibits such limitation. Some jurisdictions do not allow the exclusion or limitation of incidental or consequential damages, so this exclusion and limitation may not apply to You.
Covered Software is provided under this License on an “as is” basis, without warranty of any kind, either expressed, implied, or statutory, including, without limitation, warranties that the Covered Software is free of defects, merchantable, fit for a particular purpose or non-infringing. The entire risk as to the quality and performance of the Covered Software is with You. Should any Covered Software prove defective in any respect, You (not any Contributor) assume the cost of any necessary servicing, repair, or correction. This disclaimer of warranty constitutes an essential part of this License. No use of any Covered Software is authorized under this License except under this disclaimer.
8. Litigation Any litigation relating to this License may be brought only in the courts of a jurisdiction where the defendant maintains its principal place of business and such litigation shall be governed by laws of that jurisdiction, without reference to its conflict-of-law provisions. Nothing in this Section shall prevent a partys ability to bring cross-claims or counter-claims.
7. Limitation of Liability
9. Miscellaneous This License represents the complete agreement concerning the subject matter hereof. If any provision of this License is held to be unenforceable, such provision shall be reformed only to the extent necessary to make it enforceable. Any law or regulation which provides that the language of a contract shall be construed against the drafter shall not be used to construe this License against a Contributor.
Under no circumstances and under no legal theory, whether tort (including negligence), contract, or otherwise, shall any Contributor, or anyone who distributes Covered Software as permitted above, be liable to You for any direct, indirect, special, incidental, or consequential damages of any character including, without limitation, damages for lost profits, loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses, even if such party shall have been informed of the possibility of such damages. This limitation of liability shall not apply to liability for death or personal injury resulting from such partys negligence to the extent applicable law prohibits such limitation. Some jurisdictions do not allow the exclusion or limitation of incidental or consequential damages, so this exclusion and limitation may not apply to You.
10. Versions of the License 10.1. New Versions Mozilla Foundation is the license steward. Except as provided in Section 10.3, no one other than the license steward has the right to modify or publish new versions of this License. Each version will be given a distinguishing version number.
8. Litigation
Any litigation relating to this License may be brought only in the courts of a jurisdiction where the defendant maintains its principal place of business and such litigation shall be governed by laws of that jurisdiction, without reference to its conflict-of-law provisions. Nothing in this Section shall prevent a partys ability to bring cross-claims or counter-claims.
9. Miscellaneous
This License represents the complete agreement concerning the subject matter hereof. If any provision of this License is held to be unenforceable, such provision shall be reformed only to the extent necessary to make it enforceable. Any law or regulation which provides that the language of a contract shall be construed against the drafter shall not be used to construe this License against a Contributor.
10. Versions of the License
10.1. New Versions Mozilla Foundation is the license steward. Except as provided in Section 10.3, no one other than the license steward has the right to modify or publish new versions of this License. Each version will be given a distinguishing version number.
10.2. Effect of New Versions You may distribute the Covered Software under the terms of the version of the License under which You originally received the Covered Software, or under the terms of any subsequent version published by the license steward.
@ -100,10 +120,14 @@ You may distribute such Executable Form under the terms of this License, or subl
10.4. Distributing Source Code Form that is Incompatible With Secondary Licenses If You choose to distribute Source Code Form that is Incompatible With Secondary Licenses under the terms of this version of the License, the notice described in Exhibit B of this License must be attached.
Exhibit A - Source Code Form License Notice This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
Exhibit A - Source Code Form License Notice
This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
If it is not possible or desirable to put the notice in a particular file, then You may include the notice in a location (such as a LICENSE file in a relevant directory) where a recipient would be likely to look for such a notice.
You may add additional accurate notices of copyright ownership.
Exhibit B - “Incompatible With Secondary Licenses” Notice This Source Code Form is “Incompatible With Secondary Licenses”, as defined by the Mozilla Public License, v. 2.0.
Exhibit B - “Incompatible With Secondary Licenses” Notice
This Source Code Form is “Incompatible With Secondary Licenses”, as defined by the Mozilla Public License, v. 2.0.

View File

@ -13,6 +13,10 @@ WTF (aka 'wtfutil') is the personal information dashboard for your terminal, pro
Used by thousands of developers and tech people around the world, WTF is free and open-source. To support the continued use and development of WTF, please consider sponsoring WTF via [GitHub Sponsors](https://github.com/sponsors/senorprogrammer).
### Are you a contributor or sponsor?
Awesome! [See here](https://wtfutil.com/#exit-message) for how you can change the exit message, the message WTF shows when quitting, to something special just for you.
#
<p></p>
@ -128,7 +132,11 @@ docker cp wtf_build:/usr/local/bin/wtfutil ~/.local/bin
docker rm wtf_build
```
**Note:** WTF is _only_ compatible with Go versions **1.12.0** or later (due to the use of Go modules and newer standard library functions). If you would like to use `gccgo` to compile, you _must_ use `gccgo-9` or later which introduces support for Go modules.
**Note:** WTF is _only_ compatible with Go versions **1.16.0** or later (due to the use of Go modules and newer standard library functions). If you would like to use `gccgo` to compile, you _must_ use `gccgo-9` or later which introduces support for Go modules.
### Installing via Arch User Repository
Arch Linux users can utilise the [wtfutil](https://aur.archlinux.org/packages/wtfutil) package to build it from source, or [wtfutil-bin](https://aur.archlinux.org/packages/wtfutil-bin/) to install pre-built binaries.
## Running via Docker
@ -168,8 +176,8 @@ Also, follow [on Twitter](https://twitter.com/wtfutil) for news and latest updat
See [https://wtfutil.com](https://wtfutil.com) for the definitive
documentation. Here's some short-cuts:
* [Installation](https://wtfutil.com/getting_started/installation/)
* [Configuration](https://wtfutil.com/configuration/)
* [Installation](https://wtfutil.com/quick_start/)
* [Configuration](https://wtfutil.com/configuration/files/)
* [Module Documentation](https://wtfutil.com/modules/)
## Modules
@ -396,6 +404,27 @@ Dependency management in WTF is handled by [Go modules](https://github.com/golan
<td align="center"><a href="https://github.com/fmotrifork"><img src="https://avatars3.githubusercontent.com/u/18327738?v=4" width="48px;" alt=""/><br /><sub><b>Frederik Mogensen</b></sub></a><br /></td>
<td align="center"><a href="https://github.com/aeter"><img src="https://avatars0.githubusercontent.com/u/238607?v=4" width="48px;" alt=""/><br /><sub><b>aeter</b></sub></a><br /></td>
<td align="center"><a href="http://timhwang21.gitbook.io"><img src="https://avatars3.githubusercontent.com/u/5831434?v=4" width="48px;" alt=""/><br /><sub><b>Tim Hwang</b></sub></a><br /></td>
<td align="center"><a href="http://about.me/yingfan"><img src="https://avatars1.githubusercontent.com/u/10404961?v=4" width="48px;" alt=""/><br /><sub><b>Ying Fan Chong</b></sub></a><br /></td>
<td align="center"><a href="https://github.com/MartinJohns"><img src="https://avatars1.githubusercontent.com/u/5269069?v=4" width="48px;" alt=""/><br /><sub><b>Martin Johns</b></sub></a><br /></td>
<td align="center"><a href="https://www.jvt.me"><img src="https://avatars0.githubusercontent.com/u/3315059?v=4" width="48px;" alt=""/><br /><sub><b>Jamie Tanna</b></sub></a><br /></td>
<td align="center"><a href="https://github.com/trimble"><img src="https://avatars3.githubusercontent.com/u/371317?v=4" width="48px;" alt=""/><br /><sub><b>Todd Trimble</b></sub></a><br /></td>
</tr>
<tr>
<td align="center"><a href="https://www.mitchellhanberg.com"><img src="https://avatars2.githubusercontent.com/u/5523984?v=4" width="48px;" alt=""/><br /><sub><b>Mitchell Hanberg</b></sub></a><br /></td>
<td align="center"><a href="https://franga2000.com"><img src="https://avatars3.githubusercontent.com/u/3891092?v=4" width="48px;" alt=""/><br /><sub><b>Miha Frangež</b></sub></a><br /></td>
<td align="center"><a href="https://blog.sahilister.in/"><img src="https://avatars0.githubusercontent.com/u/52946452?v=4" width="48px;" alt=""/><br /><sub><b>Sahil Dhiman</b></sub></a><br /></td>
<td align="center"><a href="https://pzoo.netlify.app/"><img src="https://avatars2.githubusercontent.com/u/17727004?v=4" width="48px;" alt=""/><br /><sub><b>Pingzhou &#124; 平舟</b></sub></a><br /></td>
<td align="center"><a href="https://github.com/YuviGold"><img src="https://avatars0.githubusercontent.com/u/29873449?v=4" width="48px;" alt=""/><br /><sub><b>Yuval Goldberg</b></sub></a><br /></td>
<td align="center"><a href="https://github.com/dabcoder"><img src="https://avatars3.githubusercontent.com/u/5034531?v=4" width="48px;" alt=""/><br /><sub><b>David Bouchare</b></sub></a><br /></td>
<td align="center"><a href="https://github.com/stone"><img src="https://avatars3.githubusercontent.com/u/29077?v=4" width="48px;" alt=""/><br /><sub><b>Fredrik Steen</b></sub></a><br /></td>
</tr>
<tr>
<td align="center"><a href="https://github.com/zye1996"><img src="https://avatars2.githubusercontent.com/u/28901953?v=4" width="48px;" alt=""/><br /><sub><b>zye1996</b></sub></a><br /></td>
<td align="center"><a href="https://github.com/pgaxatte"><img src="https://avatars.githubusercontent.com/u/30696904?v=4" width="48px;" alt=""/><br /><sub><b>Pierre Gaxatte</b></sub></a><br /></td>
<td align="center"><a href="https://xntrik.wtf"><img src="https://avatars.githubusercontent.com/u/678260?v=4" width="48px;" alt=""/><br /><sub><b>Christian Frichot</b></sub></a><br /></td>
<td align="center"><a href="https://lukas-kaemmerling.de"><img src="https://avatars.githubusercontent.com/u/4281581?v=4" width="48px;" alt=""/><br /><sub><b>Lukas Kämmerling</b></sub></a><br /></td>
<td align="center"><a href="https://inetant.net/"><img src="https://avatars.githubusercontent.com/u/1765366?v=4" width="48px;" alt=""/><br /><sub><b>Antoine Meillet</b></sub></a><br /></td>
<td align="center"><a href="https://www.patreon.com/cclauss"><img src="https://avatars.githubusercontent.com/u/3709715?v=4" width="48px;" alt=""/><br /><sub><b>Christian Clauss</b></sub></a><br /></td>
</tr>
</table>

View File

@ -19,4 +19,3 @@ wtf:
height: 2
width: 2
refreshInterval: 30
updateInterval: 15

71
app/app_manager.go Normal file
View File

@ -0,0 +1,71 @@
package app
import (
"errors"
"github.com/olebedev/config"
"github.com/rivo/tview"
)
// WtfAppManager handles the instances of WtfApp, ensuring that they're displayed as requested
type WtfAppManager struct {
WtfApps []*WtfApp
selected int
}
// NewAppManager creates and returns an instance of AppManager
func NewAppManager() WtfAppManager {
appMan := WtfAppManager{
WtfApps: []*WtfApp{},
}
return appMan
}
// MakeNewWtfApp creates and starts a new instance of WtfApp from a set of configuration params
func (appMan *WtfAppManager) MakeNewWtfApp(config *config.Config, configFilePath string) {
wtfApp := NewWtfApp(tview.NewApplication(), config, configFilePath)
appMan.Add(wtfApp)
wtfApp.Start()
}
// Add adds a WtfApp to the collection of apps that the AppManager manages.
// This app is then available for display onscreen.
func (appMan *WtfAppManager) Add(wtfApp *WtfApp) {
appMan.WtfApps = append(appMan.WtfApps, wtfApp)
}
// Current returns the currently-displaying instance of WtfApp
func (appMan *WtfAppManager) Current() (*WtfApp, error) {
if appMan.selected < 0 || appMan.selected >= len(appMan.WtfApps) {
return nil, errors.New("invalid app index selected")
}
return appMan.WtfApps[appMan.selected], nil
}
// Next cycles the WtfApps forward by one, making the next one in the list
// the current one. If there are none after the current one, it wraps around.
func (appMan *WtfAppManager) Next() (*WtfApp, error) {
appMan.selected++
if appMan.selected >= len(appMan.WtfApps) {
appMan.selected = 0
}
return appMan.Current()
}
// Prev cycles the WtfApps backwards by one, making the previous one in the
// list the current one. If there are none before the current one, it wraps around.
func (appMan *WtfAppManager) Prev() (*WtfApp, error) {
appMan.selected--
if appMan.selected < 0 {
appMan.selected = len(appMan.WtfApps) - 1
}
return appMan.Current()
}

104
app/exit_message.go Normal file
View File

@ -0,0 +1,104 @@
package app
import (
"fmt"
"os"
"strings"
"github.com/logrusorgru/aurora"
"github.com/olebedev/config"
)
const exitMessageHeader = `
____ __ ____ .___________. _______
\ \ / \ / / | || ____|
\ \/ \/ / ----| |-----| |__
\ / | | | __|
\ /\ / | | | |
\__/ \__/ |__| |__|
the personal information dashboard for your terminal
`
// DisplayExitMessage displays the onscreen exit message when the app quits
func (wtfApp *WtfApp) DisplayExitMessage() {
exitMessageIsDisplayable := readDisplayableConfig(wtfApp.config)
wtfApp.displayExitMsg(exitMessageIsDisplayable)
}
/* -------------------- Unexported Functions -------------------- */
func (wtfApp *WtfApp) displayExitMsg(exitMessageIsDisplayable bool) string {
// If a sponsor or contributor and opt out of seeing the exit message, do not display it
if (wtfApp.ghUser.IsContributor || wtfApp.ghUser.IsSponsor) && !exitMessageIsDisplayable {
return ""
}
msgs := []string{}
msgs = append(msgs, aurora.Magenta(exitMessageHeader).String())
if wtfApp.ghUser.IsContributor {
msgs = append(msgs, wtfApp.contributorThankYouMessage())
}
if wtfApp.ghUser.IsSponsor {
msgs = append(msgs, wtfApp.sponsorThankYouMessage())
}
if !wtfApp.ghUser.IsContributor && !wtfApp.ghUser.IsSponsor {
msgs = append(msgs, wtfApp.supportRequestMessage())
}
displayMsg := strings.Join(msgs, "\n")
fmt.Println(displayMsg)
return displayMsg
}
// readDisplayableConfig figures out whether or not the exit message should be displayed
// per the user's wishes. It allows contributors and sponsors to opt out of the exit message
func readDisplayableConfig(cfg *config.Config) bool {
displayExitMsg := cfg.UBool("wtf.exitMessage.display", true)
return displayExitMsg
}
// readGitHubAPIKey attempts to find a GitHub API key somewhere in the configuration file
func readGitHubAPIKey(cfg *config.Config) string {
apiKey := cfg.UString("wtf.exitMessage.githubAPIKey", os.Getenv("WTF_GITHUB_TOKEN"))
if apiKey != "" {
return apiKey
}
moduleConfig, err := cfg.Get("wtf.mods.github")
if err != nil {
return ""
}
return moduleConfig.UString("apiKey", "")
}
/* -------------------- Messaging -------------------- */
func (wtfApp *WtfApp) contributorThankYouMessage() string {
str := " On behalf of all the users of WTF, thank you for contributing to the source code."
str += fmt.Sprintf(" %s", aurora.Green("\n\n You rock."))
return str
}
func (wtfApp *WtfApp) sponsorThankYouMessage() string {
str := " Your sponsorship of WTF makes a difference. Thank you for sponsoring and supporting WTF."
str += fmt.Sprintf(" %s", aurora.Green("\n\n You're awesome."))
return str
}
func (wtfApp *WtfApp) supportRequestMessage() string {
str := " The development and maintenance of WTF is supported by sponsorships.\n"
str += fmt.Sprintf(" Please consider sponsoring WTF at %s\n", aurora.Green("https://github.com/sponsors/senorprogrammer"))
return str
}

71
app/exit_message_test.go Normal file
View File

@ -0,0 +1,71 @@
package app
import (
"strings"
"testing"
"github.com/wtfutil/wtf/support"
"gotest.tools/assert"
)
func Test_displayExitMessage(t *testing.T) {
tests := []struct {
name string
isDisplayable bool
isContributor bool
isSponsor bool
compareWith string
expected string
}{
{
name: "when not displayable",
isDisplayable: false,
isContributor: true,
isSponsor: true,
compareWith: "equals",
expected: "",
},
{
name: "when contributor",
isDisplayable: true,
isContributor: true,
compareWith: "contains",
expected: "thank you for contributing",
},
{
name: "when sponsor",
isDisplayable: true,
isSponsor: true,
compareWith: "contains",
expected: "Thank you for sponsoring",
},
{
name: "when user",
isDisplayable: true,
isContributor: false,
isSponsor: false,
compareWith: "contains",
expected: "supported by sponsorships",
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
wtfApp := WtfApp{}
wtfApp.ghUser = &support.GitHubUser{
IsContributor: tt.isContributor,
IsSponsor: tt.isSponsor,
}
actual := wtfApp.displayExitMsg(tt.isDisplayable)
if tt.compareWith == "equals" {
assert.Equal(t, actual, tt.expected)
}
if tt.compareWith == "contains" {
assert.Equal(t, true, strings.Contains(actual, tt.expected))
}
})
}
}

View File

@ -1,6 +1,7 @@
package app
import (
"fmt"
"sort"
"github.com/olebedev/config"
@ -8,6 +9,7 @@ import (
"github.com/wtfutil/wtf/wtf"
)
// FocusState is a custom type that differentiates focusable scopes
type FocusState int
const (
@ -19,17 +21,18 @@ const (
// FocusTracker is used by the app to track which onscreen widget currently has focus,
// and to move focus between widgets.
type FocusTracker struct {
App *tview.Application
Idx int
IsFocused bool
Widgets []wtf.Wtfable
config *config.Config
config *config.Config
tviewApp *tview.Application
}
func NewFocusTracker(app *tview.Application, widgets []wtf.Wtfable, config *config.Config) FocusTracker {
// NewFocusTracker creates and returns an instance of FocusTracker
func NewFocusTracker(tviewApp *tview.Application, widgets []wtf.Wtfable, config *config.Config) FocusTracker {
focusTracker := FocusTracker{
App: app,
tviewApp: tviewApp,
Idx: -1,
IsFocused: false,
Widgets: widgets,
@ -44,6 +47,7 @@ func NewFocusTracker(app *tview.Application, widgets []wtf.Wtfable, config *conf
/* -------------------- Exported Functions -------------------- */
// FocusOn puts the focus on the item that belongs to the focus character passed in
func (tracker *FocusTracker) FocusOn(char string) bool {
if !tracker.useNavShortcuts() {
return false
@ -107,6 +111,7 @@ func (tracker *FocusTracker) Prev() {
tracker.IsFocused = true
}
// Refocus forces the focus back to the currently-selected item
func (tracker *FocusTracker) Refocus() {
tracker.focus(tracker.Idx)
}
@ -115,6 +120,7 @@ func (tracker *FocusTracker) Refocus() {
// AssignHotKeys assigns an alphabetic keyboard character to each focusable
// widget so that the widget can be brought into focus by pressing that keyboard key
// Valid numbers are between 1 and 9, inclusive
func (tracker *FocusTracker) assignHotKeys() {
if !tracker.useNavShortcuts() {
return
@ -122,30 +128,37 @@ func (tracker *FocusTracker) assignHotKeys() {
usedKeys := make(map[string]bool)
focusables := tracker.focusables()
i := 1
// First, block out the explicitly-defined characters so they can't be automatically
// assigned to other modules
for _, focusable := range focusables {
if focusable.FocusChar() != "" {
usedKeys[focusable.FocusChar()] = true
}
}
focusNum := 1
// Range over all the modules and assign focus characters to any that are focusable
// and don't have explicitly-defined focus characters
for _, focusable := range focusables {
if focusable.FocusChar() != "" {
continue
}
if _, foundKey := usedKeys[string('0'+i)]; foundKey {
for ; foundKey; _, foundKey = usedKeys[string('0'+i)] {
i++
if _, foundKey := usedKeys[fmt.Sprint(focusNum)]; foundKey {
for ; foundKey; _, foundKey = usedKeys[fmt.Sprint(focusNum)] {
focusNum++
}
}
// Don't have nav characters > "9"
if i >= 10 {
// Don't allow focus characters > "9"
if focusNum >= 10 {
break
}
focusable.SetFocusChar(string('0' + i))
i++
focusable.SetFocusChar(fmt.Sprint(focusNum))
focusNum++
}
}
@ -187,7 +200,7 @@ func (tracker *FocusTracker) focus(idx int) {
widget.CommonSettings().Colors.BorderTheme.Focused,
),
)
tracker.App.SetFocus(view)
tracker.tviewApp.SetFocus(view)
}
func (tracker *FocusTracker) focusables() []wtf.Wtfable {
@ -230,7 +243,7 @@ func (tracker *FocusTracker) focusState() FocusState {
}
for _, widget := range tracker.Widgets {
if widget.TextView() == tracker.App.GetFocus() {
if widget.TextView() == tracker.tviewApp.GetFocus() {
return widgetFocused
}
}

View File

@ -5,55 +5,77 @@ import (
"os"
"github.com/logrusorgru/aurora"
"github.com/wtfutil/wtf/cfg"
"github.com/wtfutil/wtf/wtf"
)
// ModuleValidator is responsible for validating the state of a module's configuration
type ModuleValidator struct{}
type widgetError struct {
name string
validationErrors []cfg.Validatable
}
// NewModuleValidator creates and returns an instance of ModuleValidator
func NewModuleValidator() *ModuleValidator {
val := &ModuleValidator{}
return val
return &ModuleValidator{}
}
// Validate rolls through all the enabled widgets and looks for configuration errors.
// If it finds any it stringifies them, writes them to the console, and kills the app gracefully
func (val *ModuleValidator) Validate(widgets []wtf.Wtfable) {
var errStr string
hasErrors := false
validationErrors := validate(widgets)
for _, widget := range widgets {
var widgetErrStr string
for _, val := range widget.CommonSettings().Validations() {
if val.HasError() {
hasErrors = true
widgetErrStr += fmt.Sprintf(" - %s\t%s %v\n", val, aurora.Red("Error:"), val.Error())
if len(validationErrors) > 0 {
fmt.Println()
for _, error := range validationErrors {
for _, message := range error.errorMessages() {
fmt.Println(message)
}
}
if widgetErrStr != "" {
errStr += fmt.Sprintf(
"%s\n",
fmt.Sprintf(
"%s in %s configuration",
aurora.Red("Errors"),
aurora.Yellow(
fmt.Sprintf(
"%s.position",
widget.Name(),
),
),
),
)
errStr += widgetErrStr + "\n"
}
}
if hasErrors {
fmt.Println()
fmt.Println(errStr)
os.Exit(1)
}
}
func validate(widgets []wtf.Wtfable) (widgetErrors []widgetError) {
for _, widget := range widgets {
error := widgetError{name: widget.Name()}
for _, val := range widget.CommonSettings().Validations() {
if val.HasError() {
error.validationErrors = append(error.validationErrors, val)
}
}
if len(error.validationErrors) > 0 {
widgetErrors = append(widgetErrors, error)
}
}
return widgetErrors
}
func (err widgetError) errorMessages() (messages []string) {
widgetMessage := fmt.Sprintf(
"%s in %s configuration",
aurora.Red("Errors"),
aurora.Yellow(
fmt.Sprintf(
"%s.position",
err.name,
),
),
)
messages = append(messages, widgetMessage)
for _, e := range err.validationErrors {
configMessage := fmt.Sprintf(" - %s\t%s %v", e.String(), aurora.Red("Error:"), e.Error())
messages = append(messages, configMessage)
}
return messages
}

View File

@ -0,0 +1,102 @@
package app
import (
"fmt"
"testing"
"github.com/logrusorgru/aurora"
"github.com/olebedev/config"
"github.com/stretchr/testify/assert"
"github.com/wtfutil/wtf/wtf"
)
const (
valid = `
wtf:
mods:
clocks:
enabled: true
position:
top: 0
left: 0
height: 1
width: 1
refreshInterval: 30`
invalid = `
wtf:
mods:
clocks:
enabled: true
position:
top: abc
left: 0
height: 1
width: 1
refreshInterval: 30`
)
func Test_NewModuleValidator(t *testing.T) {
assert.IsType(t, &ModuleValidator{}, NewModuleValidator())
}
func Test_validate(t *testing.T) {
tests := []struct {
name string
moduleName string
config *config.Config
expected []string
}{
{
name: "valid config",
moduleName: "clocks",
config: func() *config.Config {
cfg, _ := config.ParseYaml(valid)
return cfg
}(),
expected: []string{},
},
{
name: "invalid config",
moduleName: "clocks",
config: func() *config.Config {
cfg, _ := config.ParseYaml(invalid)
return cfg
}(),
expected: []string{
fmt.Sprintf("%s in %s configuration", aurora.Red("Errors"), aurora.Yellow("clocks.position")),
fmt.Sprintf(
" - Invalid value for %s: 0 %s strconv.ParseInt: parsing \"abc\": invalid syntax",
aurora.Yellow("top"),
aurora.Red("Error:"),
),
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
widget := MakeWidget(nil, nil, tt.moduleName, tt.config)
if widget == nil {
t.Logf("Failed to create widget %s", tt.moduleName)
t.FailNow()
}
errs := validate([]wtf.Wtfable{widget})
if len(tt.expected) == 0 {
assert.Empty(t, errs)
} else {
assert.NotEmpty(t, errs)
var actual []string
for _, err := range errs {
actual = append(actual, err.errorMessages()...)
}
assert.Equal(t, tt.expected, actual)
}
})
}
}

View File

@ -3,6 +3,7 @@ package app
import (
"github.com/olebedev/config"
"github.com/rivo/tview"
"github.com/wtfutil/wtf/modules/asana"
"github.com/wtfutil/wtf/modules/azuredevops"
"github.com/wtfutil/wtf/modules/bamboohr"
"github.com/wtfutil/wtf/modules/bargraph"
@ -13,6 +14,7 @@ import (
"github.com/wtfutil/wtf/modules/circleci"
"github.com/wtfutil/wtf/modules/clocks"
"github.com/wtfutil/wtf/modules/cmdrunner"
"github.com/wtfutil/wtf/modules/covid"
"github.com/wtfutil/wtf/modules/cryptoexchanges/bittrex"
"github.com/wtfutil/wtf/modules/cryptoexchanges/blockfolio"
"github.com/wtfutil/wtf/modules/cryptoexchanges/cryptolive"
@ -32,13 +34,16 @@ import (
"github.com/wtfutil/wtf/modules/gitlabtodo"
"github.com/wtfutil/wtf/modules/gitter"
"github.com/wtfutil/wtf/modules/googleanalytics"
"github.com/wtfutil/wtf/modules/grafana"
"github.com/wtfutil/wtf/modules/gspreadsheets"
"github.com/wtfutil/wtf/modules/hackernews"
"github.com/wtfutil/wtf/modules/healthchecks"
"github.com/wtfutil/wtf/modules/hibp"
"github.com/wtfutil/wtf/modules/ipaddresses/ipapi"
"github.com/wtfutil/wtf/modules/ipaddresses/ipinfo"
"github.com/wtfutil/wtf/modules/jenkins"
"github.com/wtfutil/wtf/modules/jira"
"github.com/wtfutil/wtf/modules/krisinformation"
"github.com/wtfutil/wtf/modules/kubernetes"
"github.com/wtfutil/wtf/modules/logger"
"github.com/wtfutil/wtf/modules/mercurial"
@ -56,17 +61,19 @@ import (
"github.com/wtfutil/wtf/modules/spotify"
"github.com/wtfutil/wtf/modules/spotifyweb"
"github.com/wtfutil/wtf/modules/status"
"github.com/wtfutil/wtf/modules/stocks/finnhub"
"github.com/wtfutil/wtf/modules/stocks/yfinance"
"github.com/wtfutil/wtf/modules/subreddit"
"github.com/wtfutil/wtf/modules/textfile"
"github.com/wtfutil/wtf/modules/todo"
"github.com/wtfutil/wtf/modules/todoist"
"github.com/wtfutil/wtf/modules/todo_plus"
"github.com/wtfutil/wtf/modules/transmission"
"github.com/wtfutil/wtf/modules/travisci"
"github.com/wtfutil/wtf/modules/trello"
"github.com/wtfutil/wtf/modules/twitch"
"github.com/wtfutil/wtf/modules/twitter"
"github.com/wtfutil/wtf/modules/twitterstats"
"github.com/wtfutil/wtf/modules/unknown"
"github.com/wtfutil/wtf/modules/uptimerobot"
"github.com/wtfutil/wtf/modules/victorops"
"github.com/wtfutil/wtf/modules/weatherservices/arpansagovau"
"github.com/wtfutil/wtf/modules/weatherservices/prettyweather"
@ -77,7 +84,7 @@ import (
// MakeWidget creates and returns instances of widgets
func MakeWidget(
app *tview.Application,
tviewApp *tview.Application,
pages *tview.Pages,
moduleName string,
config *config.Config,
@ -100,224 +107,251 @@ func MakeWidget(
switch moduleConfig.UString("type", moduleName) {
case "arpansagovau":
settings := arpansagovau.NewSettingsFromYAML(moduleName, moduleConfig, config)
widget = arpansagovau.NewWidget(app, settings)
widget = arpansagovau.NewWidget(tviewApp, settings)
case "asana":
settings := asana.NewSettingsFromYAML(moduleName, moduleConfig, config)
widget = asana.NewWidget(tviewApp, pages, settings)
case "azuredevops":
settings := azuredevops.NewSettingsFromYAML(moduleName, moduleConfig, config)
widget = azuredevops.NewWidget(app, pages, settings)
widget = azuredevops.NewWidget(tviewApp, pages, settings)
case "bamboohr":
settings := bamboohr.NewSettingsFromYAML(moduleName, moduleConfig, config)
widget = bamboohr.NewWidget(app, settings)
widget = bamboohr.NewWidget(tviewApp, settings)
case "bargraph":
settings := bargraph.NewSettingsFromYAML(moduleName, moduleConfig, config)
widget = bargraph.NewWidget(app, settings)
widget = bargraph.NewWidget(tviewApp, settings)
case "bittrex":
settings := bittrex.NewSettingsFromYAML(moduleName, moduleConfig, config)
widget = bittrex.NewWidget(app, settings)
widget = bittrex.NewWidget(tviewApp, settings)
case "blockfolio":
settings := blockfolio.NewSettingsFromYAML(moduleName, moduleConfig, config)
widget = blockfolio.NewWidget(app, settings)
widget = blockfolio.NewWidget(tviewApp, settings)
case "buildkite":
settings := buildkite.NewSettingsFromYAML(moduleName, moduleConfig, config)
widget = buildkite.NewWidget(app, pages, settings)
widget = buildkite.NewWidget(tviewApp, pages, settings)
case "cdsFavorites":
settings := cdsfavorites.NewSettingsFromYAML(moduleName, moduleConfig, config)
widget = cdsfavorites.NewWidget(app, pages, settings)
widget = cdsfavorites.NewWidget(tviewApp, pages, settings)
case "cdsQueue":
settings := cdsqueue.NewSettingsFromYAML(moduleName, moduleConfig, config)
widget = cdsqueue.NewWidget(app, pages, settings)
widget = cdsqueue.NewWidget(tviewApp, pages, settings)
case "cdsStatus":
settings := cdsstatus.NewSettingsFromYAML(moduleName, moduleConfig, config)
widget = cdsstatus.NewWidget(app, pages, settings)
widget = cdsstatus.NewWidget(tviewApp, pages, settings)
case "circleci":
settings := circleci.NewSettingsFromYAML(moduleName, moduleConfig, config)
widget = circleci.NewWidget(app, settings)
widget = circleci.NewWidget(tviewApp, settings)
case "clocks":
settings := clocks.NewSettingsFromYAML(moduleName, moduleConfig, config)
widget = clocks.NewWidget(app, settings)
widget = clocks.NewWidget(tviewApp, settings)
case "covid":
settings := covid.NewSettingsFromYAML(moduleName, moduleConfig, config)
widget = covid.NewWidget(tviewApp, settings)
case "cmdrunner":
settings := cmdrunner.NewSettingsFromYAML(moduleName, moduleConfig, config)
widget = cmdrunner.NewWidget(app, settings)
widget = cmdrunner.NewWidget(tviewApp, settings)
case "cryptolive":
settings := cryptolive.NewSettingsFromYAML(moduleName, moduleConfig, config)
widget = cryptolive.NewWidget(app, settings)
widget = cryptolive.NewWidget(tviewApp, settings)
case "datadog":
settings := datadog.NewSettingsFromYAML(moduleName, moduleConfig, config)
widget = datadog.NewWidget(app, pages, settings)
widget = datadog.NewWidget(tviewApp, pages, settings)
case "devto":
settings := devto.NewSettingsFromYAML(moduleName, moduleConfig, config)
widget = devto.NewWidget(app, pages, settings)
widget = devto.NewWidget(tviewApp, pages, settings)
case "digitalclock":
settings := digitalclock.NewSettingsFromYAML(moduleName, moduleConfig, config)
widget = digitalclock.NewWidget(app, settings)
widget = digitalclock.NewWidget(tviewApp, settings)
case "digitalocean":
settings := digitalocean.NewSettingsFromYAML(moduleName, moduleConfig, config)
widget = digitalocean.NewWidget(app, pages, settings)
widget = digitalocean.NewWidget(tviewApp, pages, settings)
case "docker":
settings := docker.NewSettingsFromYAML(moduleName, moduleConfig, config)
widget = docker.NewWidget(app, pages, settings)
widget = docker.NewWidget(tviewApp, pages, settings)
case "feedreader":
settings := feedreader.NewSettingsFromYAML(moduleName, moduleConfig, config)
widget = feedreader.NewWidget(app, pages, settings)
widget = feedreader.NewWidget(tviewApp, pages, settings)
case "football":
settings := football.NewSettingsFromYAML(moduleName, moduleConfig, config)
widget = football.NewWidget(app, pages, settings)
widget = football.NewWidget(tviewApp, pages, settings)
case "gcal":
settings := gcal.NewSettingsFromYAML(moduleName, moduleConfig, config)
widget = gcal.NewWidget(app, settings)
widget = gcal.NewWidget(tviewApp, settings)
case "gerrit":
settings := gerrit.NewSettingsFromYAML(moduleName, moduleConfig, config)
widget = gerrit.NewWidget(app, pages, settings)
widget = gerrit.NewWidget(tviewApp, pages, settings)
case "git":
settings := git.NewSettingsFromYAML(moduleName, moduleConfig, config)
widget = git.NewWidget(app, pages, settings)
widget = git.NewWidget(tviewApp, pages, settings)
case "github":
settings := github.NewSettingsFromYAML(moduleName, moduleConfig, config)
widget = github.NewWidget(app, pages, settings)
widget = github.NewWidget(tviewApp, pages, settings)
case "gitlab":
settings := gitlab.NewSettingsFromYAML(moduleName, moduleConfig, config)
widget = gitlab.NewWidget(app, pages, settings)
widget = gitlab.NewWidget(tviewApp, pages, settings)
case "gitlabtodo":
settings := gitlabtodo.NewSettingsFromYAML(moduleName, moduleConfig, config)
widget = gitlabtodo.NewWidget(app, pages, settings)
widget = gitlabtodo.NewWidget(tviewApp, pages, settings)
case "gitter":
settings := gitter.NewSettingsFromYAML(moduleName, moduleConfig, config)
widget = gitter.NewWidget(app, pages, settings)
widget = gitter.NewWidget(tviewApp, pages, settings)
case "googleanalytics":
settings := googleanalytics.NewSettingsFromYAML(moduleName, moduleConfig, config)
widget = googleanalytics.NewWidget(app, settings)
widget = googleanalytics.NewWidget(tviewApp, settings)
case "gspreadsheets":
settings := gspreadsheets.NewSettingsFromYAML(moduleName, moduleConfig, config)
widget = gspreadsheets.NewWidget(app, settings)
widget = gspreadsheets.NewWidget(tviewApp, settings)
case "grafana":
settings := grafana.NewSettingsFromYAML(moduleName, moduleConfig, config)
widget = grafana.NewWidget(tviewApp, pages, settings)
case "hackernews":
settings := hackernews.NewSettingsFromYAML(moduleName, moduleConfig, config)
widget = hackernews.NewWidget(app, pages, settings)
widget = hackernews.NewWidget(tviewApp, pages, settings)
case "healthchecks":
settings := healthchecks.NewSettingsFromYAML(moduleName, moduleConfig, config)
widget = healthchecks.NewWidget(tviewApp, pages, settings)
case "hibp":
settings := hibp.NewSettingsFromYAML(moduleName, moduleConfig, config)
widget = hibp.NewWidget(app, settings)
widget = hibp.NewWidget(tviewApp, settings)
case "ipapi":
settings := ipapi.NewSettingsFromYAML(moduleName, moduleConfig, config)
widget = ipapi.NewWidget(app, settings)
widget = ipapi.NewWidget(tviewApp, settings)
case "ipinfo":
settings := ipinfo.NewSettingsFromYAML(moduleName, moduleConfig, config)
widget = ipinfo.NewWidget(app, settings)
widget = ipinfo.NewWidget(tviewApp, settings)
case "jenkins":
settings := jenkins.NewSettingsFromYAML(moduleName, moduleConfig, config)
widget = jenkins.NewWidget(app, pages, settings)
widget = jenkins.NewWidget(tviewApp, pages, settings)
case "jira":
settings := jira.NewSettingsFromYAML(moduleName, moduleConfig, config)
widget = jira.NewWidget(app, pages, settings)
widget = jira.NewWidget(tviewApp, pages, settings)
case "kubernetes":
settings := kubernetes.NewSettingsFromYAML(moduleName, moduleConfig, config)
widget = kubernetes.NewWidget(app, settings)
widget = kubernetes.NewWidget(tviewApp, settings)
case "krisinformation":
settings := krisinformation.NewSettingsFromYAML(moduleName, moduleConfig, config)
widget = krisinformation.NewWidget(tviewApp, settings)
case "logger":
settings := logger.NewSettingsFromYAML(moduleName, moduleConfig, config)
widget = logger.NewWidget(app, settings)
widget = logger.NewWidget(tviewApp, settings)
case "mercurial":
settings := mercurial.NewSettingsFromYAML(moduleName, moduleConfig, config)
widget = mercurial.NewWidget(app, pages, settings)
widget = mercurial.NewWidget(tviewApp, pages, settings)
case "nbascore":
settings := nbascore.NewSettingsFromYAML(moduleName, moduleConfig, config)
widget = nbascore.NewWidget(app, pages, settings)
widget = nbascore.NewWidget(tviewApp, pages, settings)
case "newrelic":
settings := newrelic.NewSettingsFromYAML(moduleName, moduleConfig, config)
widget = newrelic.NewWidget(app, pages, settings)
widget = newrelic.NewWidget(tviewApp, pages, settings)
case "opsgenie":
settings := opsgenie.NewSettingsFromYAML(moduleName, moduleConfig, config)
widget = opsgenie.NewWidget(app, settings)
widget = opsgenie.NewWidget(tviewApp, settings)
case "pagerduty":
settings := pagerduty.NewSettingsFromYAML(moduleName, moduleConfig, config)
widget = pagerduty.NewWidget(app, settings)
widget = pagerduty.NewWidget(tviewApp, settings)
case "pihole":
settings := pihole.NewSettingsFromYAML(moduleName, moduleConfig, config)
widget = pihole.NewWidget(app, pages, settings)
widget = pihole.NewWidget(tviewApp, pages, settings)
case "power":
settings := power.NewSettingsFromYAML(moduleName, moduleConfig, config)
widget = power.NewWidget(app, settings)
widget = power.NewWidget(tviewApp, settings)
case "prettyweather":
settings := prettyweather.NewSettingsFromYAML(moduleName, moduleConfig, config)
widget = prettyweather.NewWidget(app, settings)
widget = prettyweather.NewWidget(tviewApp, settings)
case "pocket":
settings := pocket.NewSettingsFromYAML(moduleName, moduleConfig, config)
widget = pocket.NewWidget(app, pages, settings)
widget = pocket.NewWidget(tviewApp, pages, settings)
case "resourceusage":
settings := resourceusage.NewSettingsFromYAML(moduleName, moduleConfig, config)
widget = resourceusage.NewWidget(app, settings)
widget = resourceusage.NewWidget(tviewApp, settings)
case "rollbar":
settings := rollbar.NewSettingsFromYAML(moduleName, moduleConfig, config)
widget = rollbar.NewWidget(app, pages, settings)
widget = rollbar.NewWidget(tviewApp, pages, settings)
case "security":
settings := security.NewSettingsFromYAML(moduleName, moduleConfig, config)
widget = security.NewWidget(app, settings)
widget = security.NewWidget(tviewApp, settings)
case "spacex":
settings := spacex.NewSettingsFromYAML(moduleName, moduleConfig, config)
widget = spacex.NewWidget(app, settings)
widget = spacex.NewWidget(tviewApp, settings)
case "spotify":
settings := spotify.NewSettingsFromYAML(moduleName, moduleConfig, config)
widget = spotify.NewWidget(app, pages, settings)
widget = spotify.NewWidget(tviewApp, pages, settings)
case "spotifyweb":
settings := spotifyweb.NewSettingsFromYAML(moduleName, moduleConfig, config)
widget = spotifyweb.NewWidget(app, pages, settings)
widget = spotifyweb.NewWidget(tviewApp, pages, settings)
case "status":
settings := status.NewSettingsFromYAML(moduleName, moduleConfig, config)
widget = status.NewWidget(app, settings)
widget = status.NewWidget(tviewApp, settings)
case "subreddit":
settings := subreddit.NewSettingsFromYAML(moduleName, moduleConfig, config)
widget = subreddit.NewWidget(app, pages, settings)
widget = subreddit.NewWidget(tviewApp, pages, settings)
case "textfile":
settings := textfile.NewSettingsFromYAML(moduleName, moduleConfig, config)
widget = textfile.NewWidget(app, pages, settings)
widget = textfile.NewWidget(tviewApp, pages, settings)
case "todo":
settings := todo.NewSettingsFromYAML(moduleName, moduleConfig, config)
widget = todo.NewWidget(app, pages, settings)
widget = todo.NewWidget(tviewApp, pages, settings)
case "todo_plus":
settings := todo_plus.NewSettingsFromYAML(moduleName, moduleConfig, config)
widget = todo_plus.NewWidget(tviewApp, pages, settings)
case "todoist":
settings := todoist.NewSettingsFromYAML(moduleName, moduleConfig, config)
widget = todoist.NewWidget(app, pages, settings)
settings := todo_plus.FromTodoist(moduleName, moduleConfig, config)
widget = todo_plus.NewWidget(tviewApp, pages, settings)
case "transmission":
settings := transmission.NewSettingsFromYAML(moduleName, moduleConfig, config)
widget = transmission.NewWidget(app, pages, settings)
widget = transmission.NewWidget(tviewApp, pages, settings)
case "travisci":
settings := travisci.NewSettingsFromYAML(moduleName, moduleConfig, config)
widget = travisci.NewWidget(app, pages, settings)
widget = travisci.NewWidget(tviewApp, pages, settings)
case "trello":
settings := trello.NewSettingsFromYAML(moduleName, moduleConfig, config)
widget = trello.NewWidget(app, settings)
settings := todo_plus.FromTrello(moduleName, moduleConfig, config)
widget = todo_plus.NewWidget(tviewApp, pages, settings)
case "twitch":
settings := twitch.NewSettingsFromYAML(moduleName, moduleConfig, config)
widget = twitch.NewWidget(app, pages, settings)
widget = twitch.NewWidget(tviewApp, pages, settings)
case "twitter":
settings := twitter.NewSettingsFromYAML(moduleName, moduleConfig, config)
widget = twitter.NewWidget(app, pages, settings)
widget = twitter.NewWidget(tviewApp, pages, settings)
case "twitterstats":
settings := twitterstats.NewSettingsFromYAML(moduleName, moduleConfig, config)
widget = twitterstats.NewWidget(app, pages, settings)
widget = twitterstats.NewWidget(tviewApp, pages, settings)
case "uptimerobot":
settings := uptimerobot.NewSettingsFromYAML(moduleName, moduleConfig, config)
widget = uptimerobot.NewWidget(tviewApp, pages, settings)
case "victorops":
settings := victorops.NewSettingsFromYAML(moduleName, moduleConfig, config)
widget = victorops.NewWidget(app, settings)
widget = victorops.NewWidget(tviewApp, settings)
case "weather":
settings := weather.NewSettingsFromYAML(moduleName, moduleConfig, config)
widget = weather.NewWidget(app, pages, settings)
widget = weather.NewWidget(tviewApp, pages, settings)
case "zendesk":
settings := zendesk.NewSettingsFromYAML(moduleName, moduleConfig, config)
widget = zendesk.NewWidget(app, pages, settings)
widget = zendesk.NewWidget(tviewApp, pages, settings)
case "exchangerates":
settings := exchangerates.NewSettingsFromYAML(moduleName, moduleConfig, config)
widget = exchangerates.NewWidget(app, pages, settings)
widget = exchangerates.NewWidget(tviewApp, pages, settings)
case "finnhub":
settings := finnhub.NewSettingsFromYAML(moduleName, moduleConfig, config)
widget = finnhub.NewWidget(tviewApp, settings)
case "yfinance":
settings := yfinance.NewSettingsFromYAML(moduleName, moduleConfig, config)
widget = yfinance.NewWidget(tviewApp, settings)
default:
settings := unknown.NewSettingsFromYAML(moduleName, moduleConfig, config)
widget = unknown.NewWidget(app, settings)
widget = unknown.NewWidget(tviewApp, settings)
}
return widget
}
// MakeWidgets creates and returns a collection of enabled widgets
func MakeWidgets(app *tview.Application, pages *tview.Pages, config *config.Config) []wtf.Wtfable {
func MakeWidgets(tviewApp *tview.Application, pages *tview.Pages, config *config.Config) []wtf.Wtfable {
widgets := []wtf.Wtfable{}
moduleNames, _ := config.Map("wtf.mods")
for moduleName := range moduleNames {
widget := MakeWidget(app, pages, moduleName, config)
widget := MakeWidget(tviewApp, pages, moduleName, config)
if widget != nil {
widgets = append(widgets, widget)

View File

@ -1,15 +1,19 @@
package app
import (
"fmt"
"log"
"os"
"time"
"github.com/gdamore/tcell"
_ "github.com/gdamore/tcell/terminfo/extended"
"github.com/logrusorgru/aurora"
"github.com/olebedev/config"
"github.com/radovskyb/watcher"
"github.com/rivo/tview"
"github.com/wtfutil/wtf/cfg"
"github.com/wtfutil/wtf/support"
"github.com/wtfutil/wtf/utils"
"github.com/wtfutil/wtf/wtf"
)
@ -17,39 +21,42 @@ import (
// WtfApp is the container for a collection of widgets that are all constructed from a single
// configuration file and displayed together
type WtfApp struct {
app *tview.Application
TViewApp *tview.Application
config *config.Config
configFilePath string
display *Display
focusTracker FocusTracker
ghUser *support.GitHubUser
pages *tview.Pages
validator *ModuleValidator
widgets []wtf.Wtfable
}
// NewWtfApp creates and returns an instance of WtfApp
func NewWtfApp(app *tview.Application, config *config.Config, configFilePath string) *WtfApp {
wtfApp := WtfApp{
app: app,
func NewWtfApp(tviewApp *tview.Application, config *config.Config, configFilePath string) *WtfApp {
wtfApp := &WtfApp{
TViewApp: tviewApp,
config: config,
configFilePath: configFilePath,
pages: tview.NewPages(),
}
wtfApp.app.SetBeforeDrawFunc(func(s tcell.Screen) bool {
wtfApp.TViewApp.SetBeforeDrawFunc(func(s tcell.Screen) bool {
s.Clear()
return false
})
wtfApp.app.SetInputCapture(wtfApp.keyboardIntercept)
wtfApp.widgets = MakeWidgets(wtfApp.app, wtfApp.pages, wtfApp.config)
wtfApp.widgets = MakeWidgets(wtfApp.TViewApp, wtfApp.pages, wtfApp.config)
wtfApp.display = NewDisplay(wtfApp.widgets, wtfApp.config)
wtfApp.focusTracker = NewFocusTracker(wtfApp.app, wtfApp.widgets, wtfApp.config)
wtfApp.focusTracker = NewFocusTracker(wtfApp.TViewApp, wtfApp.widgets, wtfApp.config)
wtfApp.validator = NewModuleValidator()
githubAPIKey := readGitHubAPIKey(wtfApp.config)
wtfApp.ghUser = support.NewGitHubUser(githubAPIKey)
wtfApp.pages.AddPage("grid", wtfApp.display.Grid, true, true)
wtfApp.app.SetRoot(wtfApp.pages, true)
wtfApp.validator.Validate(wtfApp.widgets)
@ -60,15 +67,29 @@ func NewWtfApp(app *tview.Application, config *config.Config, configFilePath str
),
)
return &wtfApp
wtfApp.TViewApp.SetInputCapture(wtfApp.keyboardIntercept)
wtfApp.TViewApp.SetRoot(wtfApp.pages, true)
return wtfApp
}
/* -------------------- Exported Functions -------------------- */
// Run starts the underlying tview app
func (wtfApp *WtfApp) Run() {
if err := wtfApp.TViewApp.Run(); err != nil {
fmt.Printf("\n%s %v\n", aurora.Red("ERROR"), err)
os.Exit(1)
}
}
// Start initializes the app
func (wtfApp *WtfApp) Start() {
wtfApp.scheduleWidgets()
go wtfApp.scheduleWidgets()
go wtfApp.watchForConfigChanges()
// FIXME: This should be moved to the AppManager
go func() { _ = wtfApp.ghUser.Load() }()
}
// Stop kills all the currently-running widgets in this app
@ -87,9 +108,18 @@ func (wtfApp *WtfApp) stopAllWidgets() {
func (wtfApp *WtfApp) keyboardIntercept(event *tcell.EventKey) *tcell.EventKey {
// These keys are global keys used by the app. Widgets should not implement these keys
switch event.Key() {
case tcell.KeyCtrlC:
wtfApp.Stop()
wtfApp.TViewApp.Stop()
wtfApp.DisplayExitMessage()
case tcell.KeyCtrlR:
wtfApp.refreshAllWidgets()
return nil
case tcell.KeyCtrlSpace:
// FIXME: This can't reside in the app, the app doesn't know about
// the AppManager. The AppManager needs to catch this one
fmt.Println("Next app")
return nil
case tcell.KeyTab:
wtfApp.focusTracker.Next()
case tcell.KeyBacktab:
@ -141,9 +171,9 @@ func (wtfApp *WtfApp) watchForConfigChanges() {
wtfApp.Stop()
config := cfg.LoadWtfConfigFile(wtfApp.configFilePath)
newApp := NewWtfApp(wtfApp.app, config, wtfApp.configFilePath)
openUrlUtil := utils.ToStrs(config.UList("wtf.openUrlUtil", []interface{}{}))
utils.Init(config.UString("wtf.openFileUtil", "open"), openUrlUtil)
newApp := NewWtfApp(wtfApp.TViewApp, config, wtfApp.configFilePath)
openURLUtil := utils.ToStrs(config.UList("wtf.openUrlUtil", []interface{}{}))
utils.Init(config.UString("wtf.openFileUtil", "open"), openURLUtil)
newApp.Start()
case err := <-watch.Error:

View File

@ -5,6 +5,12 @@ import (
"strings"
"github.com/olebedev/config"
"golang.org/x/text/language"
"golang.org/x/text/message"
)
const (
defaultLanguageTag = "en-CA"
)
type Module struct {
@ -23,27 +29,32 @@ type Sigils struct {
}
}
// Common defines a set of common configuration settings applicable to all modules
type Common struct {
Module
PositionSettings `help:"Defines where in the grid this modules widget will be displayed."`
Sigils
Colors ColorTheme
Colors ColorTheme
Config *config.Config
DocPath string
Bordered bool `help:"Whether or not the module should be displayed with a border." values:"true, false" optional:"true" default:"true"`
Enabled bool `help:"Whether or not this module is executed and if its data displayed onscreen." values:"true, false" optional:"true" default:"false"`
Focusable bool `help:"Whether or not this module is focusable." values:"true, false" optional:"true" default:"false"`
LanguageTag string `help:"The BCP 47 langauge tag to localize text to." values:"Any supported BCP 47 language tag." optional:"true" default:"en-CA"`
RefreshInterval int `help:"How often, in seconds, this module will update its data." values:"A positive integer, 0..n." optional:"true"`
Title string `help:"The title string to show when displaying this module" optional:"true"`
Config *config.Config
focusChar int `help:"Define one of the number keys as a short cut key to access the widget." optional:"true"`
}
// NewCommonSettingsFromModule returns a common settings configuration tailed to the given module
func NewCommonSettingsFromModule(name, defaultTitle string, defaultFocusable bool, moduleConfig *config.Config, globalSettings *config.Config) *Common {
func NewCommonSettingsFromModule(name, defaultTitle string, defaultFocusable bool, moduleConfig *config.Config, globalConfig *config.Config) *Common {
baseColors := NewDefaultColorTheme()
colorsConfig, err := globalSettings.Get("wtf.colors")
colorsConfig, err := globalConfig.Get("wtf.colors")
if err != nil && strings.Contains(err.Error(), "Nonexistent map") {
// Create a default colors config to fill in for the missing one
// This comes into play when the configuration file does not contain a `colors:` key, i.e:
@ -90,6 +101,7 @@ func NewCommonSettingsFromModule(name, defaultTitle string, defaultFocusable boo
Config: moduleConfig,
Enabled: moduleConfig.UBool("enabled", false),
Focusable: moduleConfig.UBool("focusable", defaultFocusable),
LanguageTag: globalConfig.UString("wtf.language", defaultLanguageTag),
RefreshInterval: moduleConfig.UInt("refreshInterval", 300),
Title: moduleConfig.UString("title", defaultTitle),
@ -97,11 +109,10 @@ func NewCommonSettingsFromModule(name, defaultTitle string, defaultFocusable boo
}
sigilsPath := "wtf.sigils"
common.Sigils.Checkbox.Checked = globalSettings.UString(sigilsPath+".checkbox.checked", "x")
common.Sigils.Checkbox.Unchecked = globalSettings.UString(sigilsPath+".checkbox.unchecked", " ")
common.Sigils.Paging.Normal = globalSettings.UString(sigilsPath+".paging.normal", globalSettings.UString("wtf.paging.pageSigil", "*"))
common.Sigils.Paging.Selected = globalSettings.UString(sigilsPath+".paging.select", globalSettings.UString("wtf.paging.selectedSigil", "_"))
common.Sigils.Checkbox.Checked = globalConfig.UString(sigilsPath+".checkbox.checked", "x")
common.Sigils.Checkbox.Unchecked = globalConfig.UString(sigilsPath+".checkbox.unchecked", " ")
common.Sigils.Paging.Normal = globalConfig.UString(sigilsPath+".paging.normal", globalConfig.UString("wtf.paging.pageSigil", "*"))
common.Sigils.Paging.Selected = globalConfig.UString(sigilsPath+".paging.select", globalConfig.UString("wtf.paging.selectedSigil", "_"))
return &common
}
@ -124,12 +135,32 @@ func (common *Common) DefaultRowColor() string {
)
}
// FocusChar returns the keyboard number assigned to the widget used to give onscreen
// focus to this widget, as a string. Focus characters can be a range between 1 and 9
func (common *Common) FocusChar() string {
if common.focusChar <= -1 {
if common.focusChar <= 0 {
return ""
}
return string('0' + common.focusChar)
if common.focusChar > 9 {
return ""
}
return fmt.Sprint(common.focusChar)
}
// LocalizedPrinter returns a message.Printer instance localized to the BCP 47 language
// configuration value defined in 'wtf.language' config. If none exists, it defaults to
// 'en-CA'. Use this to format numbers, etc.
func (common *Common) LocalizedPrinter() (*message.Printer, error) {
langTag, err := language.Parse(common.LanguageTag)
if err != nil {
return nil, err
}
prntr := message.NewPrinter(langTag)
return prntr, nil
}
func (common *Common) RowColor(idx int) string {
@ -145,7 +176,9 @@ func (common *Common) RightAlignFormat(width int) string {
return fmt.Sprintf("%%%ds", width-borderOffset)
}
func (common *Common) SigilStr(len, pos, width int) string {
// PaginationMarker generates the pagination indicators that appear in the top-right corner
// of multisource widgets
func (common *Common) PaginationMarker(len, pos, width int) string {
sigils := ""
if len > 1 {
@ -159,6 +192,15 @@ func (common *Common) SigilStr(len, pos, width int) string {
return sigils
}
// SetDocumentationPath is used to explicitly set the documentation path that should be opened
// when the key to open the documentation is pressed.
// Setting this is probably not necessary unless the module documentation is nested inside a
// documentation subdirectory in the /wtfutildocs repo, or the module here has a different
// name than the module's display name in the documentation (which ideally wouldn't be a thing).
func (common *Common) SetDocumentationPath(path string) {
common.DocPath = path
}
// Validations aggregates all the validations from all the sub-sections in Common into a
// single array of validations
func (common *Common) Validations() []Validatable {

View File

@ -47,29 +47,36 @@ func Test_DefaultRowColor(t *testing.T) {
func Test_FocusChar(t *testing.T) {
tests := []struct {
name string
expectedChar string
before func(testCfg *Common)
expectedChar string
}{
{
name: "with no focus char specified",
expectedChar: "",
name: "with negative focus char",
before: func(testCfg *Common) {
testCfg.focusChar = -1
},
expectedChar: "",
},
{
name: "with explicit focus char specified",
expectedChar: "3",
name: "with positive focus char",
before: func(testCfg *Common) {
testCfg.focusChar = 3
},
expectedChar: "3",
},
{
name: "with ridiculous focus char specified",
expectedChar: "Q",
name: "with zero focus char",
before: func(testCfg *Common) {
testCfg.focusChar = 33
testCfg.focusChar = 0
},
expectedChar: "",
},
{
name: "with large focus char",
before: func(testCfg *Common) {
testCfg.focusChar = 10
},
expectedChar: "",
},
}
@ -137,7 +144,7 @@ func Test_RightAlignFormat(t *testing.T) {
}
}
func Test_SigilStr(t *testing.T) {
func Test_PaginationMarker(t *testing.T) {
tests := []struct {
name string
len int
@ -177,7 +184,7 @@ func Test_SigilStr(t *testing.T) {
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
assert.Equal(t, tt.expected, testCfg.SigilStr(tt.len, tt.pos, tt.width))
assert.Equal(t, tt.expected, testCfg.PaginationMarker(tt.len, tt.pos, tt.width))
})
}
}

View File

@ -29,7 +29,7 @@ const (
// CreateFile creates the named file in the config directory, if it does not already exist.
// If the file exists it does not recreate it.
// If successful, eturns the absolute path to the file
// If successful, returns the absolute path to the file
// If unsuccessful, returns an error
func CreateFile(fileName string) (string, error) {
configDir, err := WtfConfigDir()
@ -37,7 +37,7 @@ func CreateFile(fileName string) (string, error) {
return "", err
}
filePath := fmt.Sprintf("%s/%s", configDir, fileName)
filePath := filepath.Join(configDir, fileName)
// Check if the file already exists; if it does not, create it
_, err = os.Stat(filePath)
@ -106,7 +106,7 @@ func LoadWtfConfigFile(filePath string) *config.Config {
// chmodConfigFile sets the mode of the config file to r+w for the owner only
func chmodConfigFile() {
configDir, _ := WtfConfigDir()
relPath := fmt.Sprintf("%s%s", configDir, WtfConfigFile)
relPath := filepath.Join(configDir, WtfConfigFile)
absPath, _ := expandHomeDir(relPath)
_, err := os.Stat(absPath)

View File

@ -36,7 +36,7 @@ const defaultConfigFile = `wtf:
odd: "white"
enabled: true
locations:
Avignon: "Europe/Paris"
Paris: "Europe/Paris"
Barcelona: "Europe/Madrid"
Dubai: "Asia/Dubai"
position:
@ -58,7 +58,7 @@ const defaultConfigFile = `wtf:
left: 1
width: 2
height: 1
updateInterval: 14400
refreshInterval: 14400
ipinfo:
colors:
name: "lightblue"

View File

@ -40,8 +40,6 @@ func main() {
generateWidgetFile(data)
generateSettingsFile(data)
fmt.Println("Done")
}
/* -------------------- Unexported Functions -------------------- */

View File

@ -9,16 +9,14 @@ import (
type Widget struct {
view.TextWidget
app *tview.Application
settings *Settings
}
// NewWidget creates and returns an instance of Widget
func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *Widget {
func NewWidget(tviewApp *tview.Application, pages *tview.Pages, settings *Settings) *Widget {
widget := Widget{
TextWidget: view.NewTextWidget(app, settings.common),
TextWidget: view.NewTextWidget(tviewApp, settings.common),
app: app,
settings: settings,
}

48
go.mod
View File

@ -1,74 +1,76 @@
module github.com/wtfutil/wtf
go 1.14
go 1.16
require (
bitbucket.org/mikehouston/asana-go v0.0.0-20201102222432-715318d0343a
code.cloudfoundry.org/bytefmt v0.0.0-20190819182555-854d396b647c
github.com/Azure/go-autorest v11.1.2+incompatible // indirect
github.com/Microsoft/go-winio v0.4.14 // indirect
github.com/PagerDuty/go-pagerduty v0.0.0-20191002190746-f60f4fc45222
github.com/StackExchange/wmi v0.0.0-20190523213315-cbe66965904d // indirect
github.com/VictorAvelar/devto-api-go v1.0.0
github.com/adlio/trello v1.7.0
github.com/alecthomas/chroma v0.8.0
github.com/adlio/trello v1.8.0
github.com/alecthomas/chroma v0.8.1
github.com/andygrunwald/go-gerrit v0.0.0-20190825170856-5959a9bf9ff8
github.com/briandowns/openweathermap v0.0.0-20180804155945-5f41b7c9d92d
github.com/cenkalti/backoff v2.2.1+incompatible // indirect
github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e
github.com/digitalocean/godo v1.42.1
github.com/creack/pty v1.1.11
github.com/digitalocean/godo v1.52.0
github.com/docker/distribution v2.7.1+incompatible // indirect
github.com/docker/docker v1.13.1
github.com/docker/docker-credential-helpers v0.6.3
github.com/docker/go-connections v0.4.0 // indirect
github.com/docker/go-units v0.4.0 // indirect
github.com/dustin/go-humanize v1.0.0
github.com/facebookgo/ensure v0.0.0-20200202191622-63f1cf65ac4c // indirect
github.com/facebookgo/freeport v0.0.0-20150612182905-d4adf43b75b9 // indirect
github.com/facebookgo/stack v0.0.0-20160209184415-751773369052 // indirect
github.com/facebookgo/subset v0.0.0-20200203212716-c811ad88dec4 // indirect
github.com/gdamore/tcell v1.3.0
github.com/gdamore/tcell v1.4.0
github.com/go-ole/go-ole v1.2.4 // indirect
github.com/godbus/dbus v4.1.0+incompatible // indirect
github.com/google/go-github/v26 v26.1.3
github.com/google/go-github/v32 v32.1.0
github.com/gophercloud/gophercloud v0.5.0 // indirect
github.com/hekmon/cunits v2.0.1+incompatible // indirect
github.com/hekmon/transmissionrpc v0.0.0-20190525133028-1d589625bacd
github.com/imdario/mergo v0.3.8 // indirect
github.com/jedib0t/go-pretty/v6 v6.1.0
github.com/jessevdk/go-flags v1.4.0
github.com/kr/text v0.2.0 // indirect
github.com/lib/pq v1.2.0 // indirect
github.com/logrusorgru/aurora v0.0.0-20190803045625-94edacc10f9b
github.com/microsoft/azure-devops-go-api/azuredevops v0.0.0-20191014190507-26902c1d4325
github.com/mmcdole/gofeed v1.0.0
github.com/nicklaw5/helix v0.5.9
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e // indirect
github.com/mmcdole/gofeed v1.1.0
github.com/nicklaw5/helix v0.7.0
github.com/olebedev/config v0.0.0-20190528211619-364964f3a8e4
github.com/olekukonko/tablewriter v0.0.4
github.com/onsi/ginkgo v1.12.0 // indirect
github.com/onsi/gomega v1.9.0 // indirect
github.com/ovh/cds v0.0.0-20200131143542-5e69464c6598
github.com/ovh/cds v0.0.0-20201014170613-39429542624d
github.com/pborman/uuid v1.2.0 // indirect
github.com/piquette/finance-go v1.0.0
github.com/pkg/errors v0.9.1
github.com/pkg/profile v1.5.0
github.com/radovskyb/watcher v1.0.7
github.com/rivo/tview v0.0.0-20200108161608-1316ea7a4b35
github.com/shirou/gopsutil v2.20.7+incompatible
github.com/shirou/gopsutil v2.20.9+incompatible
github.com/shopspring/decimal v1.2.0 // indirect
github.com/shurcooL/githubv4 v0.0.0-20200802174311-f27d2ca7f6d5
github.com/shurcooL/graphql v0.0.0-20181231061246-d48a9a75455f // indirect
github.com/spf13/cobra v0.0.5 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/spf13/viper v1.6.1 // indirect
github.com/ssor/bom v0.0.0-20170718123548-6386211fdfcf // indirect
github.com/stretchr/testify v1.6.1
github.com/wtfutil/spotigopher v0.0.0-20191127141047-7d8168fe103a
github.com/wtfutil/todoist v0.0.2-0.20191216004217-0ec29ceda61a
github.com/xanzy/go-gitlab v0.33.0
github.com/xanzy/go-gitlab v0.39.0
github.com/zmb3/spotify v0.0.0-20191010212056-e12fb981aacb
github.com/zorkian/go-datadog-api v2.29.0+incompatible
golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d
golang.org/x/text v0.3.3
google.golang.org/api v0.30.0
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f // indirect
github.com/zorkian/go-datadog-api v2.30.0+incompatible
golang.org/x/oauth2 v0.0.0-20200902213428-5d25da1a8d43
golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208
golang.org/x/text v0.3.4
google.golang.org/api v0.33.0
gopkg.in/jarcoal/httpmock.v1 v1.0.0-20181110093347-3be5f16b70eb // indirect
gopkg.in/yaml.v2 v2.3.0
gotest.tools v2.2.0+incompatible
jaytaylor.com/html2text v0.0.0-20200412013138-3577fbdbcff7
k8s.io/apimachinery v0.0.0-20190223094358-dcb391cde5ca
k8s.io/client-go v10.0.0+incompatible
)

452
go.sum

File diff suppressed because it is too large Load Diff

53
main.go
View File

@ -1,44 +1,31 @@
package main
// Generators
// To generate the skeleton for a new TextWidget use 'WTF_WIDGET_NAME=MySuperAwesomeWidget go generate -run=text
//go:generate -command text go run generator/textwidget.go
//go:generate text
import (
"fmt"
"log"
"os"
// Blank import of tzdata embeds the timezone database to allow Windows hosts to find timezone
// information even if the timezone database is not available on the local system. See release
// notes at https://golang.org/doc/go1.15#time/tzdata for details. This prevents "no timezone
// data available" errors in clocks module.
_ "time/tzdata"
"github.com/logrusorgru/aurora"
"github.com/olebedev/config"
"github.com/pkg/profile"
"github.com/rivo/tview"
"github.com/wtfutil/wtf/app"
"github.com/wtfutil/wtf/cfg"
"github.com/wtfutil/wtf/flags"
"github.com/wtfutil/wtf/utils"
"github.com/wtfutil/wtf/wtf"
)
var tviewApp *tview.Application
var (
date = "dev"
version = "dev"
)
/* -------------------- Functions -------------------- */
func setTerm(config *config.Config) {
term := config.UString("wtf.term", os.Getenv("TERM"))
err := os.Setenv("TERM", term)
if err != nil {
fmt.Printf("\n%s Failed to set $TERM to %s.\n", aurora.Red("ERROR"), aurora.Yellow(term))
os.Exit(1)
}
}
/* -------------------- Main -------------------- */
func main() {
@ -48,29 +35,31 @@ func main() {
flags := flags.NewFlags()
flags.Parse()
hasCustom := flags.HasCustomConfig()
cfg.Initialize(hasCustom)
// Load the configuration file
cfg.Initialize(flags.HasCustomConfig())
config := cfg.LoadWtfConfigFile(flags.ConfigFilePath())
wtf.SetTerminal(config)
flags.RenderIf(version, date, config)
if flags.Profile {
defer profile.Start(profile.MemProfile).Stop()
}
openUrlUtil := utils.ToStrs(config.UList("wtf.openUrlUtil", []interface{}{}))
utils.Init(config.UString("wtf.openFileUtil", "open"), openUrlUtil)
openFileUtil := config.UString("wtf.openFileUtil", "open")
openURLUtil := utils.ToStrs(config.UList("wtf.openUrlUtil", []interface{}{}))
utils.Init(openFileUtil, openURLUtil)
setTerm(config)
/* Initialize the App Manager */
appMan := app.NewAppManager()
appMan.MakeNewWtfApp(config, flags.Config)
// Build the application
tviewApp = tview.NewApplication()
wtfApp := app.NewWtfApp(tviewApp, config, flags.Config)
wtfApp.Start()
if err := tviewApp.Run(); err != nil {
currentApp, err := appMan.Current()
if err != nil {
fmt.Printf("\n%s %v\n", aurora.Red("ERROR"), err)
os.Exit(1)
}
currentApp.Run()
}

280
modules/asana/client.go Normal file
View File

@ -0,0 +1,280 @@
package asana
import (
"fmt"
"strings"
"time"
asana "bitbucket.org/mikehouston/asana-go"
)
func fetchTasksFromProject(token, projectId, mode string) ([]*TaskItem, error) {
taskItems := []*TaskItem{}
uidToName := make(map[string]string)
client := asana.NewClientWithAccessToken(token)
uid, err := getCurrentUserId(client, mode)
if err != nil {
return nil, err
}
q := &asana.TaskQuery{
Project: projectId,
}
fetchedTasks, _, err := getTasksFromAsana(client, q)
if err != nil {
return nil, fmt.Errorf("error fetching tasks: %s", err)
}
processFetchedTasks(client, &fetchedTasks, &taskItems, &uidToName, mode, projectId, uid)
return taskItems, nil
}
func fetchTasksFromProjectSections(token, projectId string, sections []string, mode string) ([]*TaskItem, error) {
taskItems := []*TaskItem{}
uidToName := make(map[string]string)
client := asana.NewClientWithAccessToken(token)
uid, err := getCurrentUserId(client, mode)
if err != nil {
return nil, err
}
p := &asana.Project{
ID: projectId,
}
for _, section := range sections {
sectionId, err := findSection(client, p, section)
if err != nil {
return nil, fmt.Errorf("error fetching tasks: %s", err)
}
q := &asana.TaskQuery{
Section: sectionId,
}
fetchedTasks, _, err := getTasksFromAsana(client, q)
if err != nil {
return nil, fmt.Errorf("error fetching tasks: %s", err)
}
if len(fetchedTasks) > 0 {
taskItem := &TaskItem{
name: section,
taskType: TASK_SECTION,
}
taskItems = append(taskItems, taskItem)
}
processFetchedTasks(client, &fetchedTasks, &taskItems, &uidToName, mode, projectId, uid)
}
return taskItems, nil
}
func fetchTasksFromWorkspace(token, workspaceId, mode string) ([]*TaskItem, error) {
taskItems := []*TaskItem{}
uidToName := make(map[string]string)
client := asana.NewClientWithAccessToken(token)
uid, err := getCurrentUserId(client, mode)
if err != nil {
return nil, err
}
q := &asana.TaskQuery{
Workspace: workspaceId,
Assignee: "me",
}
fetchedTasks, _, err := getTasksFromAsana(client, q)
if err != nil {
return nil, fmt.Errorf("error fetching tasks: %s", err)
}
processFetchedTasks(client, &fetchedTasks, &taskItems, &uidToName, mode, workspaceId, uid)
return taskItems, nil
}
func toggleTaskCompletionById(token, taskId string) error {
client := asana.NewClientWithAccessToken(token)
t := &asana.Task{
ID: taskId,
}
err := t.Fetch(client)
if err != nil {
return fmt.Errorf("error fetching task: %s", err)
}
updateReq := &asana.UpdateTaskRequest{}
if *t.Completed {
f := false
updateReq.Completed = &f
} else {
t := true
updateReq.Completed = &t
}
err = t.Update(client, updateReq)
if err != nil {
return fmt.Errorf("error updating task: %s", err)
}
return nil
}
func processFetchedTasks(client *asana.Client, fetchedTasks *[]*asana.Task, taskItems *[]*TaskItem, uidToName *map[string]string, mode, projectId, uid string) {
for _, task := range *fetchedTasks {
switch {
case strings.HasSuffix(mode, "_all"):
if task.Assignee != nil {
// Check if we have already looked up this user
if assigneeName, ok := (*uidToName)[task.Assignee.ID]; ok {
task.Assignee.Name = assigneeName
} else {
// We haven't looked up this user before, perform the lookup now
assigneeName, err := getOtherUserEmail(client, task.Assignee.ID)
if err != nil {
task.Assignee.Name = "Error"
}
(*uidToName)[task.Assignee.ID] = assigneeName
task.Assignee.Name = assigneeName
}
} else {
task.Assignee = &asana.User{
Name: "Unassigned",
}
}
taskItem := buildTaskItem(task, projectId)
(*taskItems) = append((*taskItems), taskItem)
case !strings.HasSuffix(mode, "_all") && task.Assignee != nil && task.Assignee.ID == uid:
taskItem := buildTaskItem(task, projectId)
(*taskItems) = append((*taskItems), taskItem)
}
}
}
func buildTaskItem(task *asana.Task, projectId string) *TaskItem {
dueOnString := ""
if task.DueOn != nil {
dueOn := time.Time(*task.DueOn)
currentYear, _, _ := time.Now().Date()
if currentYear != dueOn.Year() {
dueOnString = dueOn.Format("Jan 2 2006")
} else {
dueOnString = dueOn.Format("Jan 2")
}
}
assignString := ""
if task.Assignee != nil {
assignString = task.Assignee.Name
}
taskItem := &TaskItem{
name: task.Name,
id: task.ID,
numSubtasks: task.NumSubtasks,
dueOn: dueOnString,
url: fmt.Sprintf("https://app.asana.com/0/%s/%s/f", projectId, task.ID),
taskType: TASK_TYPE,
completed: *task.Completed,
assignee: assignString,
}
return taskItem
}
func getOtherUserEmail(client *asana.Client, uid string) (string, error) {
if uid == "" {
return "", fmt.Errorf("missing uid")
}
u := &asana.User{
ID: uid,
}
err := u.Fetch(client, nil)
if err != nil {
return "", fmt.Errorf("error fetching user: %s", err)
}
return u.Email, nil
}
func getCurrentUserId(client *asana.Client, mode string) (string, error) {
if strings.HasSuffix(mode, "_all") {
return "", nil
}
u, err := client.CurrentUser()
if err != nil {
return "", fmt.Errorf("error getting current user: %s", err)
}
return u.ID, nil
}
func findSection(client *asana.Client, project *asana.Project, sectionName string) (string, error) {
sectionId := ""
sections, _, err := project.Sections(client, &asana.Options{
Limit: 100,
})
if err != nil {
return "", fmt.Errorf("error getting sections: %s", err)
}
for _, section := range sections {
if section.Name == sectionName {
sectionId = section.ID
break
}
}
if sectionId == "" {
return "", fmt.Errorf("we didn't find the section %s", sectionName)
}
return sectionId, nil
}
func getTasksFromAsana(client *asana.Client, q *asana.TaskQuery) ([]*asana.Task, bool, error) {
moreTasks := false
tasks, np, err := client.QueryTasks(q, &asana.Options{
Limit: 100,
Fields: []string{
"assignee",
"name",
"num_subtasks",
"due_on",
"completed",
},
})
if err != nil {
return nil, false, fmt.Errorf("error querying tasks: %s", err)
}
if np != nil {
moreTasks = true
}
return tasks, moreTasks, nil
}

20
modules/asana/keyboard.go Normal file
View File

@ -0,0 +1,20 @@
package asana
import "github.com/gdamore/tcell"
func (widget *Widget) initializeKeyboardControls() {
widget.InitializeHelpTextKeyboardControl(widget.ShowHelp)
widget.InitializeRefreshKeyboardControl(widget.Refresh)
widget.SetKeyboardChar("j", widget.Next, "Select next task")
widget.SetKeyboardChar("k", widget.Prev, "Select previous task")
widget.SetKeyboardChar("q", widget.Unselect, "Unselect task")
widget.SetKeyboardChar("o", widget.openTask, "Open task in browser")
widget.SetKeyboardChar("x", widget.toggleTaskCompletion, "Toggles the task's completion state")
widget.SetKeyboardChar("?", widget.ShowHelp, "Shows help")
widget.SetKeyboardKey(tcell.KeyDown, widget.Next, "Select next task")
widget.SetKeyboardKey(tcell.KeyUp, widget.Prev, "Select previous task")
widget.SetKeyboardKey(tcell.KeyEsc, widget.Unselect, "Unselect task")
widget.SetKeyboardKey(tcell.KeyEnter, widget.openTask, "Open task in browser")
}

48
modules/asana/settings.go Normal file
View File

@ -0,0 +1,48 @@
package asana
import (
"github.com/olebedev/config"
"github.com/wtfutil/wtf/cfg"
"github.com/wtfutil/wtf/utils"
)
const (
defaultFocusable = true
defaultTitle = "Asana"
)
type Settings struct {
*cfg.Common
projectId string `help:"The Asana Project ID. If the mode is 'project' or 'project_sections' this is required to known which Asana Project to pull your tasks from" values:"A valid Asana Project ID string" optional:"true"`
workspaceId string `help:"The Asana Workspace ID. If mode is 'workspace' this is required" values:"A valid Asana Workspace ID string" optional:"true"`
sections []string `help:"The Asana Section Labels to fetch from the Project. Required if the mode is 'project_sections'" values:"An array of Asana Section Label strings" optional:"true"`
allUsers bool `help:"Fetch tasks for all users, defaults to false" values:"bool" optional:"true"`
mode string `help:"What mode to query Asana, 'project', 'project_sections', 'workspace'" values:"A string with either 'project', 'project_sections' or 'workspace'"`
hideComplete bool `help:"Hide completed tasks, defaults to false" values:"bool" optional:"true"`
apiKey string `help:"Your Asana Personal Access Token. Leave this blank to use the WTF_ASANA_TOKEN environment variable." values:"Your Asana Personal Access Token as a string" optional:"true"`
token string
}
func NewSettingsFromYAML(name string, ymlConfig *config.Config, globalConfig *config.Config) *Settings {
settings := Settings{
Common: cfg.NewCommonSettingsFromModule(name, defaultTitle, defaultFocusable, ymlConfig,
globalConfig),
projectId: ymlConfig.UString("projectId", ""),
apiKey: ymlConfig.UString("apiKey", ""),
workspaceId: ymlConfig.UString("workspaceId", ""),
sections: utils.ToStrs(ymlConfig.UList("sections")),
allUsers: ymlConfig.UBool("allUsers", false),
mode: ymlConfig.UString("mode", ""),
hideComplete: ymlConfig.UBool("hideComplete", false),
}
return &settings
}

259
modules/asana/widget.go Normal file
View File

@ -0,0 +1,259 @@
package asana
import (
"fmt"
"os"
"strings"
"sync"
"github.com/rivo/tview"
"github.com/wtfutil/wtf/utils"
"github.com/wtfutil/wtf/view"
)
type TaskType int
const (
TASK_TYPE TaskType = iota
TASK_SECTION
TASK_BREAK
)
type TaskItem struct {
name string
numSubtasks int32
dueOn string
id string
url string
taskType TaskType
completed bool
assignee string
}
type Widget struct {
view.ScrollableWidget
tasks []*TaskItem
mu sync.Mutex
err error
settings *Settings
tviewApp *tview.Application
}
func NewWidget(tviewApp *tview.Application, pages *tview.Pages, settings *Settings) *Widget {
widget := &Widget{
ScrollableWidget: view.NewScrollableWidget(tviewApp, pages, settings.Common),
tviewApp: tviewApp,
settings: settings,
}
widget.SetRenderFunction(widget.Render)
widget.initializeKeyboardControls()
return widget
}
/* -------------------- Exported Functions -------------------- */
func (widget *Widget) Refresh() {
widget.tasks = nil
widget.err = nil
widget.SetItemCount(0)
widget.mu.Lock()
defer widget.mu.Unlock()
tasks, err := widget.Fetch(
widget.settings.workspaceId,
widget.settings.projectId,
widget.settings.mode,
widget.settings.sections,
widget.settings.allUsers,
)
if err != nil {
widget.err = err
} else {
widget.tasks = tasks
widget.SetItemCount(len(tasks))
}
widget.Render()
}
func (widget *Widget) Render() {
widget.Redraw(widget.content)
}
func (widget *Widget) Fetch(workspaceId, projectId, mode string, sections []string, allUsers bool) ([]*TaskItem, error) {
availableModes := map[string]interface{}{
"project": nil,
"project_sections": nil,
"workspace": nil,
}
if _, ok := availableModes[mode]; !ok {
return nil, fmt.Errorf("missing mode, or mode is invalid - please set to project, project_sections or workspace")
}
if widget.settings.apiKey != "" {
widget.settings.token = widget.settings.apiKey
} else {
widget.settings.token = os.Getenv("WTF_ASANA_TOKEN")
}
if widget.settings.token == "" {
return nil, fmt.Errorf("missing environment variable token or apikey config")
}
subMode := mode
if allUsers && mode != "workspace" {
subMode += "_all"
}
if projectId == "" && strings.HasPrefix(subMode, "project") {
return nil, fmt.Errorf("missing project id")
}
if workspaceId == "" && subMode == "workspace" {
return nil, fmt.Errorf("missing workspace id")
}
var tasks []*TaskItem
var err error
switch {
case strings.HasPrefix(subMode, "project_sections"):
tasks, err = fetchTasksFromProjectSections(widget.settings.token, projectId, sections, subMode)
case strings.HasPrefix(subMode, "project"):
tasks, err = fetchTasksFromProject(widget.settings.token, projectId, subMode)
case subMode == "workspace":
tasks, err = fetchTasksFromWorkspace(widget.settings.token, workspaceId, subMode)
default:
err = fmt.Errorf("no mode found")
}
if err != nil {
return nil, err
}
return tasks, nil
}
/* -------------------- Unexported Functions -------------------- */
func (widget *Widget) content() (string, string, bool) {
title := widget.CommonSettings().Title
if widget.err != nil {
return title, widget.err.Error(), true
}
data := widget.tasks
if len(data) == 0 {
return title, "No data", false
}
var str string
for idx, taskItem := range data {
switch {
case taskItem.taskType == TASK_TYPE:
if widget.settings.hideComplete && taskItem.completed {
continue
}
rowColor := widget.RowColor(idx)
completed := "[ []"
if taskItem.completed {
completed = "[x[]"
}
row := ""
if widget.settings.allUsers && taskItem.assignee != "" {
row = fmt.Sprintf(
"[%s] %s %s: %s",
rowColor,
completed,
taskItem.assignee,
taskItem.name,
)
} else {
row = fmt.Sprintf(
"[%s] %s %s",
rowColor,
completed,
taskItem.name,
)
}
if taskItem.numSubtasks > 0 {
row += fmt.Sprintf(" (%d)", taskItem.numSubtasks)
}
if taskItem.dueOn != "" {
row += fmt.Sprintf(" due: %s", taskItem.dueOn)
}
row += " [white]"
str += utils.HighlightableHelper(widget.View, row, idx, len(taskItem.name))
case taskItem.taskType == TASK_SECTION:
if idx > 1 {
row := "[white] "
str += utils.HighlightableHelper(widget.View, row, idx, len(taskItem.name))
}
row := fmt.Sprintf(
"[white] %s [white]",
taskItem.name,
)
str += utils.HighlightableHelper(widget.View, row, idx, len(taskItem.name))
row = "[white] "
str += utils.HighlightableHelper(widget.View, row, idx, len(taskItem.name))
}
}
return title, str, false
}
func (widget *Widget) openTask() {
sel := widget.GetSelected()
if sel >= 0 && widget.tasks != nil && sel < len(widget.tasks) {
task := widget.tasks[sel]
if task.taskType == TASK_TYPE && task.url != "" {
utils.OpenFile(task.url)
}
}
}
func (widget *Widget) toggleTaskCompletion() {
sel := widget.GetSelected()
if sel >= 0 && widget.tasks != nil && sel < len(widget.tasks) {
task := widget.tasks[sel]
if task.taskType == TASK_TYPE {
widget.mu.Lock()
err := toggleTaskCompletionById(widget.settings.token, task.id)
if err != nil {
widget.err = err
}
widget.mu.Unlock()
widget.Refresh()
}
}
}

View File

@ -14,7 +14,7 @@ const (
// Settings defines the configuration options for this module
type Settings struct {
common *cfg.Common
*cfg.Common
apiToken string `help:"Your Azure DevOps Access Token."`
labelColor string
@ -26,7 +26,7 @@ type Settings struct {
// NewSettingsFromYAML creates and returns an instance of Settings with configuration options populated
func NewSettingsFromYAML(name string, ymlConfig *config.Config, globalConfig *config.Config) *Settings {
settings := Settings{
common: cfg.NewCommonSettingsFromModule(name, defaultTitle, defaultFocus, ymlConfig, globalConfig),
Common: cfg.NewCommonSettingsFromModule(name, defaultTitle, defaultFocus, ymlConfig, globalConfig),
apiToken: ymlConfig.UString("apiToken", os.Getenv("WTF_AZURE_DEVOPS_API_TOKEN")),
labelColor: ymlConfig.UString("labelColor", "white"),

View File

@ -19,9 +19,9 @@ type Widget struct {
ctx context.Context
}
func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *Widget {
func NewWidget(tviewApp *tview.Application, pages *tview.Pages, settings *Settings) *Widget {
widget := Widget{
TextWidget: view.NewTextWidget(app, settings.common),
TextWidget: view.NewTextWidget(tviewApp, pages, settings.Common),
settings: settings,
}

View File

@ -13,7 +13,7 @@ const (
)
type Settings struct {
common *cfg.Common
*cfg.Common
apiKey string `help:"Your BambooHR API token."`
subdomain string `help:"Your BambooHR API subdomain name."`
@ -21,7 +21,7 @@ type Settings struct {
func NewSettingsFromYAML(name string, ymlConfig *config.Config, globalConfig *config.Config) *Settings {
settings := Settings{
common: cfg.NewCommonSettingsFromModule(name, defaultTitle, defaultFocusable, ymlConfig, globalConfig),
Common: cfg.NewCommonSettingsFromModule(name, defaultTitle, defaultFocusable, ymlConfig, globalConfig),
apiKey: ymlConfig.UString("apiKey", ymlConfig.UString("apikey", os.Getenv("WTF_BAMBOO_HR_TOKEN"))),
subdomain: ymlConfig.UString("subdomain", os.Getenv("WTF_BAMBOO_HR_SUBDOMAIN")),

View File

@ -19,9 +19,9 @@ type Widget struct {
items []Item
}
func NewWidget(app *tview.Application, settings *Settings) *Widget {
func NewWidget(tviewApp *tview.Application, settings *Settings) *Widget {
widget := Widget{
TextWidget: view.NewTextWidget(app, settings.common),
TextWidget: view.NewTextWidget(tviewApp, nil, settings.Common),
settings: settings,
}

View File

@ -11,12 +11,12 @@ const (
)
type Settings struct {
common *cfg.Common
*cfg.Common
}
func NewSettingsFromYAML(name string, ymlConfig *config.Config, globalConfig *config.Config) *Settings {
settings := Settings{
common: cfg.NewCommonSettingsFromModule(name, defaultTitle, defaultFocusable, ymlConfig, globalConfig),
Common: cfg.NewCommonSettingsFromModule(name, defaultTitle, defaultFocusable, ymlConfig, globalConfig),
}
return &settings

View File

@ -17,15 +17,15 @@ import (
type Widget struct {
view.BarGraph
app *tview.Application
tviewApp *tview.Application
}
// NewWidget Make new instance of widget
func NewWidget(app *tview.Application, settings *Settings) *Widget {
func NewWidget(tviewApp *tview.Application, settings *Settings) *Widget {
widget := Widget{
BarGraph: view.NewBarGraph(app, "Sample Bar Graph", settings.common),
BarGraph: view.NewBarGraph(tviewApp, "Sample Bar Graph", settings.Common),
app: app,
tviewApp: tviewApp,
}
widget.View.SetWrap(true)
@ -69,7 +69,7 @@ func (widget *Widget) Refresh() {
widget.View.Clear()
widget.app.QueueUpdateDraw(func() {
widget.tviewApp.QueueUpdateDraw(func() {
display(widget)
})

View File

@ -57,6 +57,8 @@ func (widget *Widget) recentBuilds(pipeline PipelineSettings) ([]Build, error) {
if err != nil {
return nil, err
}
defer func() { _ = resp.Body.Close() }()
if resp.StatusCode < 200 || resp.StatusCode > 299 {
return nil, fmt.Errorf(resp.Status)
}

View File

@ -1,5 +1,6 @@
package buildkite
func (widget *Widget) initializeKeyboardControls() {
widget.InitializeCommonControls(widget.Refresh)
widget.InitializeHelpTextKeyboardControl(widget.ShowHelp)
widget.InitializeRefreshKeyboardControl(widget.Refresh)
}

View File

@ -21,7 +21,8 @@ type PipelineSettings struct {
// Settings defines the configuration properties for this module
type Settings struct {
common *cfg.Common
*cfg.Common
apiKey string `help:"Your Buildkite API Token"`
orgSlug string `help:"Organization Slug"`
pipelines []PipelineSettings `help:"An array of pipelines to get data from"`
@ -30,7 +31,8 @@ type Settings struct {
// NewSettingsFromYAML creates a new settings instance from a YAML config block
func NewSettingsFromYAML(name string, ymlConfig *config.Config, globalConfig *config.Config) *Settings {
settings := Settings{
common: cfg.NewCommonSettingsFromModule(name, defaultTitle, defaultFocusable, ymlConfig, globalConfig),
Common: cfg.NewCommonSettingsFromModule(name, defaultTitle, defaultFocusable, ymlConfig, globalConfig),
apiKey: ymlConfig.UString("apiKey", os.Getenv("WTF_BUILDKITE_TOKEN")),
orgSlug: ymlConfig.UString("organizationSlug"),
pipelines: buildPipelineSettings(ymlConfig),

View File

@ -7,12 +7,7 @@ import (
"github.com/wtfutil/wtf/view"
)
const HelpText = `
Keyboard commands for Buildkite:
`
type Widget struct {
view.KeyboardWidget
view.TextWidget
settings *Settings
@ -20,17 +15,14 @@ type Widget struct {
err error
}
func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *Widget {
func NewWidget(tviewApp *tview.Application, pages *tview.Pages, settings *Settings) *Widget {
widget := Widget{
KeyboardWidget: view.NewKeyboardWidget(app, pages, settings.common),
TextWidget: view.NewTextWidget(app, settings.common),
settings: settings,
TextWidget: view.NewTextWidget(tviewApp, pages, settings.Common),
settings: settings,
}
widget.initializeKeyboardControls()
widget.View.SetInputCapture(widget.InputCapture)
widget.View.SetScrollable(true)
widget.KeyboardWidget.SetView(widget.View)
return &widget
}

View File

@ -25,7 +25,7 @@ func (widget *Widget) content() (string, string, bool) {
}
_, _, width, _ := widget.View.GetRect()
str := widget.settings.common.SigilStr(len(widget.workflows), widget.Idx, width) + "\n"
str := widget.settings.PaginationMarker(len(widget.workflows), widget.Idx, width) + "\n"
title := fmt.Sprintf("%s - %s", widget.CommonSettings().Title, widget.title(workflow))
str += widget.displayWorkflowRuns(workflow)
@ -36,7 +36,7 @@ func (widget *Widget) content() (string, string, bool) {
func (widget *Widget) title(workflow *sdk.Workflow) string {
return fmt.Sprintf(
"[%s]%s/%s[white]",
widget.settings.common.Colors.TextTheme.Title,
widget.settings.Colors.TextTheme.Title,
workflow.ProjectKey, workflow.Name,
)
}

View File

@ -5,7 +5,8 @@ import (
)
func (widget *Widget) initializeKeyboardControls() {
widget.InitializeCommonControls(widget.Refresh)
widget.InitializeHelpTextKeyboardControl(widget.ShowHelp)
widget.InitializeRefreshKeyboardControl(widget.Refresh)
widget.SetKeyboardChar("j", widget.Next, "Select next workflow")
widget.SetKeyboardChar("k", widget.Prev, "Select previous workflow")

View File

@ -15,7 +15,8 @@ const (
// Settings defines the configuration properties for this module
type Settings struct {
common *cfg.Common
*cfg.Common
token string `help:"Your CDS API token."`
apiURL string `help:"Your CDS API URL."`
uiURL string
@ -25,10 +26,14 @@ type Settings struct {
// NewSettingsFromYAML creates a new settings instance from a YAML config block
func NewSettingsFromYAML(name string, ymlConfig *config.Config, globalConfig *config.Config) *Settings {
settings := Settings{
common: cfg.NewCommonSettingsFromModule(name, defaultTitle, defaultFocusable, ymlConfig, globalConfig),
Common: cfg.NewCommonSettingsFromModule(name, defaultTitle, defaultFocusable, ymlConfig, globalConfig),
token: ymlConfig.UString("token", ymlConfig.UString("token", os.Getenv("CDS_TOKEN"))),
apiURL: ymlConfig.UString("apiURL", os.Getenv("CDS_API_URL")),
hideTags: utils.ToStrs(ymlConfig.UList("hideTags")),
}
settings.SetDocumentationPath("cds/favorites")
return &settings
}

View File

@ -14,7 +14,6 @@ import (
// Widget define wtf widget to register widget later
type Widget struct {
view.MultiSourceWidget
view.KeyboardWidget
view.TextWidget
workflows []sdk.Workflow
@ -28,22 +27,19 @@ type Widget struct {
}
// NewWidget creates a new instance of the widget
func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *Widget {
func NewWidget(tviewApp *tview.Application, pages *tview.Pages, settings *Settings) *Widget {
widget := Widget{
KeyboardWidget: view.NewKeyboardWidget(app, pages, settings.common),
MultiSourceWidget: view.NewMultiSourceWidget(settings.common, "workflow", "workflows"),
TextWidget: view.NewTextWidget(app, settings.common),
MultiSourceWidget: view.NewMultiSourceWidget(settings.Common, "workflow", "workflows"),
TextWidget: view.NewTextWidget(tviewApp, pages, settings.Common),
settings: settings,
}
widget.initializeKeyboardControls()
widget.View.SetRegions(true)
widget.View.SetInputCapture(widget.InputCapture)
widget.SetDisplayFunction(widget.display)
widget.Unselect()
widget.KeyboardWidget.SetView(widget.View)
widget.client = cdsclient.New(cdsclient.Config{
Host: settings.apiURL,
@ -110,11 +106,6 @@ func (widget *Widget) Refresh() {
widget.display()
}
// HelpText displays the widgets controls
func (widget *Widget) HelpText() string {
return widget.KeyboardWidget.HelpText()
}
/* -------------------- Unexported Functions -------------------- */
func (widget *Widget) buildWorkflowsCollection() []sdk.Workflow {

View File

@ -23,7 +23,7 @@ func (widget *Widget) content() (string, string, bool) {
filter := widget.currentFilter()
_, _, width, _ := widget.View.GetRect()
str := widget.settings.common.SigilStr(len(widget.filters), widget.Idx, width) + "\n"
str := widget.settings.PaginationMarker(len(widget.filters), widget.Idx, width) + "\n"
str += widget.displayQueue(filter)
title := fmt.Sprintf("%s - %s", widget.CommonSettings().Title, widget.title(filter))
@ -34,7 +34,7 @@ func (widget *Widget) content() (string, string, bool) {
func (widget *Widget) title(filter string) string {
return fmt.Sprintf(
"[%s]%d - %s[white]",
widget.settings.common.Colors.TextTheme.Title,
widget.settings.Colors.TextTheme.Title,
widget.maxItems,
filter,
)

View File

@ -5,7 +5,8 @@ import (
)
func (widget *Widget) initializeKeyboardControls() {
widget.InitializeCommonControls(widget.Refresh)
widget.InitializeHelpTextKeyboardControl(widget.ShowHelp)
widget.InitializeRefreshKeyboardControl(widget.Refresh)
widget.SetKeyboardChar("j", widget.Next, "Select next workflow")
widget.SetKeyboardChar("k", widget.Prev, "Select previous workflow")

View File

@ -14,7 +14,8 @@ const (
// Settings defines the configuration properties for this module
type Settings struct {
common *cfg.Common
*cfg.Common
token string `help:"Your CDS API token."`
apiURL string `help:"Your CDS API URL."`
uiURL string
@ -23,9 +24,13 @@ type Settings struct {
// NewSettingsFromYAML creates a new settings instance from a YAML config block
func NewSettingsFromYAML(name string, ymlConfig *config.Config, globalConfig *config.Config) *Settings {
settings := Settings{
common: cfg.NewCommonSettingsFromModule(name, defaultTitle, defaultFocusable, ymlConfig, globalConfig),
Common: cfg.NewCommonSettingsFromModule(name, defaultTitle, defaultFocusable, ymlConfig, globalConfig),
token: ymlConfig.UString("token", ymlConfig.UString("token", os.Getenv("CDS_TOKEN"))),
apiURL: ymlConfig.UString("apiURL", os.Getenv("CDS_API_URL")),
}
settings.SetDocumentationPath("cds/queue")
return &settings
}

View File

@ -14,7 +14,6 @@ import (
// Widget define wtf widget to register widget later
type Widget struct {
view.MultiSourceWidget
view.KeyboardWidget
view.TextWidget
filters []string
@ -28,25 +27,21 @@ type Widget struct {
}
// NewWidget creates a new instance of the widget
func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *Widget {
func NewWidget(tviewApp *tview.Application, pages *tview.Pages, settings *Settings) *Widget {
widget := Widget{
KeyboardWidget: view.NewKeyboardWidget(app, pages, settings.common),
MultiSourceWidget: view.NewMultiSourceWidget(settings.common, "workflow", "workflows"),
TextWidget: view.NewTextWidget(app, settings.common),
MultiSourceWidget: view.NewMultiSourceWidget(settings.Common, "workflow", "workflows"),
TextWidget: view.NewTextWidget(tviewApp, pages, settings.Common),
settings: settings,
}
widget.initializeKeyboardControls()
widget.View.SetRegions(true)
widget.View.SetInputCapture(widget.InputCapture)
widget.SetDisplayFunction(widget.display)
widget.Unselect()
widget.filters = []string{sdk.StatusWaiting, sdk.StatusBuilding}
widget.KeyboardWidget.SetView(widget.View)
widget.client = cdsclient.New(cdsclient.Config{
Host: settings.apiURL,
BuitinConsumerAuthenticationToken: settings.token,
@ -111,11 +106,6 @@ func (widget *Widget) Refresh() {
widget.display()
}
// HelpText displays the widgets controls
func (widget *Widget) HelpText() string {
return widget.KeyboardWidget.HelpText()
}
/* -------------------- Unexported Functions -------------------- */
func (widget *Widget) currentFilter() string {

View File

@ -5,7 +5,8 @@ import (
)
func (widget *Widget) initializeKeyboardControls() {
widget.InitializeCommonControls(widget.Refresh)
widget.InitializeHelpTextKeyboardControl(widget.ShowHelp)
widget.InitializeRefreshKeyboardControl(widget.Refresh)
widget.SetKeyboardChar("j", widget.Next, "Select next line")
widget.SetKeyboardChar("k", widget.Prev, "Select previous line")

View File

@ -14,7 +14,8 @@ const (
// Settings defines the configuration properties for this module
type Settings struct {
common *cfg.Common
*cfg.Common
token string `help:"Your CDS API token."`
apiURL string `help:"Your CDS API URL."`
uiURL string
@ -23,9 +24,13 @@ type Settings struct {
// NewSettingsFromYAML creates a new settings instance from a YAML config block
func NewSettingsFromYAML(name string, ymlConfig *config.Config, globalConfig *config.Config) *Settings {
settings := Settings{
common: cfg.NewCommonSettingsFromModule(name, defaultTitle, defaultFocusable, ymlConfig, globalConfig),
Common: cfg.NewCommonSettingsFromModule(name, defaultTitle, defaultFocusable, ymlConfig, globalConfig),
token: ymlConfig.UString("token", ymlConfig.UString("token", os.Getenv("CDS_TOKEN"))),
apiURL: ymlConfig.UString("apiURL", os.Getenv("CDS_API_URL")),
}
settings.SetDocumentationPath("cds/status")
return &settings
}

View File

@ -14,7 +14,6 @@ import (
// Widget define wtf widget to register widget later
type Widget struct {
view.MultiSourceWidget
view.KeyboardWidget
view.TextWidget
filters []string
@ -28,25 +27,21 @@ type Widget struct {
}
// NewWidget creates a new instance of the widget
func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *Widget {
func NewWidget(tviewApp *tview.Application, pages *tview.Pages, settings *Settings) *Widget {
widget := Widget{
KeyboardWidget: view.NewKeyboardWidget(app, pages, settings.common),
MultiSourceWidget: view.NewMultiSourceWidget(settings.common, "workflow", "workflows"),
TextWidget: view.NewTextWidget(app, settings.common),
MultiSourceWidget: view.NewMultiSourceWidget(settings.Common, "workflow", "workflows"),
TextWidget: view.NewTextWidget(tviewApp, pages, settings.Common),
settings: settings,
}
widget.initializeKeyboardControls()
widget.View.SetRegions(true)
widget.View.SetInputCapture(widget.InputCapture)
widget.SetDisplayFunction(widget.display)
widget.Unselect()
widget.filters = []string{sdk.StatusWaiting, sdk.StatusBuilding}
widget.KeyboardWidget.SetView(widget.View)
widget.client = cdsclient.New(cdsclient.Config{
Host: settings.apiURL,
BuitinConsumerAuthenticationToken: settings.token,
@ -111,11 +106,6 @@ func (widget *Widget) Refresh() {
widget.display()
}
// HelpText displays the widgets controls
func (widget *Widget) HelpText() string {
return widget.KeyboardWidget.HelpText()
}
/* -------------------- Unexported Functions -------------------- */
func (widget *Widget) openWorkflow() {

View File

@ -1,7 +1,9 @@
package circleci
import (
"bytes"
"fmt"
"io/ioutil"
"net/http"
"net/url"
@ -28,7 +30,7 @@ func (client *Client) BuildsFor() ([]*Build, error) {
return builds, err
}
err = utils.ParseJSON(&builds, resp.Body)
err = utils.ParseJSON(&builds, bytes.NewReader(resp))
if err != nil {
return builds, err
}
@ -42,7 +44,7 @@ var (
circleAPIURL = &url.URL{Scheme: "https", Host: "circleci.com", Path: "/api/v1/"}
)
func (client *Client) circleRequest(path string) (*http.Response, error) {
func (client *Client) circleRequest(path string) ([]byte, error) {
params := url.Values{}
params.Add("circle-token", client.apiKey)
@ -61,9 +63,15 @@ func (client *Client) circleRequest(path string) (*http.Response, error) {
return nil, err
}
defer func() { _ = resp.Body.Close() }()
if resp.StatusCode < 200 || resp.StatusCode > 299 {
return nil, fmt.Errorf(resp.Status)
}
return resp, nil
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
return nil, err
}
return body, nil
}

View File

@ -13,17 +13,19 @@ const (
)
type Settings struct {
common *cfg.Common
*cfg.Common
apiKey string `help:"Your CircleCI API token."`
apiKey string `help:"Your CircleCI API token."`
numberOfBuilds int `help:"The number of build, 10 by default"`
}
func NewSettingsFromYAML(name string, ymlConfig *config.Config, globalConfig *config.Config) *Settings {
settings := Settings{
common: cfg.NewCommonSettingsFromModule(name, defaultTitle, defaultFocusable, ymlConfig, globalConfig),
Common: cfg.NewCommonSettingsFromModule(name, defaultTitle, defaultFocusable, ymlConfig, globalConfig),
apiKey: ymlConfig.UString("apiKey", ymlConfig.UString("apikey", os.Getenv("WTF_CIRCLE_API_KEY"))),
apiKey: ymlConfig.UString("apiKey", ymlConfig.UString("apikey", os.Getenv("WTF_CIRCLE_API_KEY"))),
numberOfBuilds: ymlConfig.UInt("numberOfBuilds", 10),
}
cfg.ModuleSecret(name, globalConfig, &settings.apiKey).Load()

View File

@ -14,9 +14,9 @@ type Widget struct {
settings *Settings
}
func NewWidget(app *tview.Application, settings *Settings) *Widget {
func NewWidget(tviewApp *tview.Application, settings *Settings) *Widget {
widget := Widget{
TextWidget: view.NewTextWidget(app, settings.common),
TextWidget: view.NewTextWidget(tviewApp, nil, settings.Common),
Client: NewClient(settings.apiKey),
settings: settings,
@ -48,7 +48,7 @@ func (widget *Widget) content() (string, string, bool) {
str = err.Error()
} else {
for idx, build := range builds {
if idx > 10 {
if idx > widget.settings.numberOfBuilds {
break
}

View File

@ -1,6 +1,7 @@
package clocks
import (
"strings"
"time"
)
@ -18,6 +19,14 @@ func NewClock(label string, timeLoc *time.Location) Clock {
return clock
}
func BuildClock(label string, location string) (clock Clock, err error) {
timeLoc, err := time.LoadLocation(sanitizeLocation(location))
if err != nil {
return Clock{}, err
}
return NewClock(label, timeLoc), nil
}
func (clock *Clock) Date(dateFormat string) string {
return clock.LocalTime().Format(dateFormat)
}
@ -33,3 +42,7 @@ func (clock *Clock) ToLocal(t time.Time) time.Time {
func (clock *Clock) Time(timeFormat string) string {
return clock.LocalTime().Format(timeFormat)
}
func sanitizeLocation(locStr string) string {
return strings.Replace(locStr, " ", "_", -1)
}

View File

@ -10,7 +10,9 @@ type ClockCollection struct {
}
func (clocks *ClockCollection) Sorted(sortOrder string) []Clock {
if sortOrder == "chronological" {
if sortOrder == "natural" {
//no-op
} else if sortOrder == "chronological" {
clocks.SortedChronologically()
} else {
clocks.SortedAlphabetically()

View File

@ -1,15 +1,13 @@
package clocks
import (
"fmt"
)
import "fmt"
func (widget *Widget) display(clocks []Clock, dateFormat string, timeFormat string) {
str := ""
if len(clocks) == 0 {
str = fmt.Sprintf("\n%s", " no timezone data available")
} else {
for idx, clock := range clocks {
str += fmt.Sprintf(
" [%s]%-12s %-10s %7s[white]\n",

View File

@ -13,24 +13,55 @@ const (
// Settings defines the configuration properties for this module
type Settings struct {
common *cfg.Common
*cfg.Common
dateFormat string `help:"The format of the date string for all clocks." values:"Any valid Go date layout which is handled by Time.Format. Defaults to Jan 2."`
timeFormat string `help:"The format of the time string for all clocks." values:"Any valid Go time layout which is handled by Time.Format. Defaults to 15:04 MST."`
locations map[string]interface{} `help:"Defines the timezones for the world clocks that you want to display. key is a unique label that will be displayed in the UI. value is a timezone name." values:"Any TZ database timezone."`
sort string `help:"Defines the display order of the clocks in the widget." values:"'alphabetical' or 'chronological'. 'alphabetical' will sort in acending order by key, 'chronological' will sort in ascending order by date/time."`
dateFormat string `help:"The format of the date string for all clocks." values:"Any valid Go date layout which is handled by Time.Format. Defaults to Jan 2."`
timeFormat string `help:"The format of the time string for all clocks." values:"Any valid Go time layout which is handled by Time.Format. Defaults to 15:04 MST."`
locations []Clock `help:"Defines the timezones for the world clocks that you want to display. key is a unique label that will be displayed in the UI. value is a timezone name." values:"Any TZ database timezone."`
sort string `help:"Defines the display order of the clocks in the widget." values:"'alphabetical', 'chronological', or 'natural. 'alphabetical' will sort in ascending order by key, 'chronological' will sort in ascending order by date/time, 'natural' will keep ordering as per the config."`
}
// NewSettingsFromYAML creates a new settings instance from a YAML config block
func NewSettingsFromYAML(name string, ymlConfig *config.Config, globalConfig *config.Config) *Settings {
settings := Settings{
common: cfg.NewCommonSettingsFromModule(name, defaultTitle, defaultFocusable, ymlConfig, globalConfig),
Common: cfg.NewCommonSettingsFromModule(name, defaultTitle, defaultFocusable, ymlConfig, globalConfig),
dateFormat: ymlConfig.UString("dateFormat", utils.SimpleDateFormat),
timeFormat: ymlConfig.UString("timeFormat", utils.SimpleTimeFormat),
locations: ymlConfig.UMap("locations"),
locations: buildLocations(ymlConfig),
sort: ymlConfig.UString("sort"),
}
return &settings
}
func buildLocations(ymlConfig *config.Config) []Clock {
clocks := []Clock{}
locations, err := ymlConfig.Map("locations")
if err == nil {
for k, v := range locations {
name := k
zone := v.(string)
clock, err := BuildClock(name, zone)
if err == nil {
clocks = append(clocks, clock)
}
}
return clocks
}
listLocations := ymlConfig.UList("locations")
for _, location := range listLocations {
if location, ok := location.(map[string]interface{}); ok {
for k, v := range location {
name := k
zone := v.(string)
clock, err := BuildClock(name, zone)
if err == nil {
clocks = append(clocks, clock)
}
}
}
}
return clocks
}

View File

@ -1,9 +1,6 @@
package clocks
import (
"strings"
"time"
"github.com/rivo/tview"
"github.com/wtfutil/wtf/view"
)
@ -11,24 +8,22 @@ import (
type Widget struct {
view.TextWidget
app *tview.Application
clockColl ClockCollection
dateFormat string
timeFormat string
settings *Settings
}
func NewWidget(app *tview.Application, settings *Settings) *Widget {
func NewWidget(tviewApp *tview.Application, settings *Settings) *Widget {
widget := Widget{
TextWidget: view.NewTextWidget(app, settings.common),
TextWidget: view.NewTextWidget(tviewApp, nil, settings.Common),
app: app,
settings: settings,
dateFormat: settings.dateFormat,
timeFormat: settings.timeFormat,
}
widget.clockColl = widget.buildClockCollection(settings.locations)
widget.clockColl = widget.buildClockCollection()
return &widget
}
@ -37,29 +32,16 @@ func NewWidget(app *tview.Application, settings *Settings) *Widget {
// Refresh updates the onscreen contents of the widget
func (widget *Widget) Refresh() {
widget.app.QueueUpdateDraw(func() {
sortedClocks := widget.clockColl.Sorted(widget.settings.sort)
widget.display(sortedClocks, widget.dateFormat, widget.timeFormat)
})
sortedClocks := widget.clockColl.Sorted(widget.settings.sort)
widget.display(sortedClocks, widget.dateFormat, widget.timeFormat)
}
/* -------------------- Unexported Functions -------------------- */
func (widget *Widget) buildClockCollection(locData map[string]interface{}) ClockCollection {
func (widget *Widget) buildClockCollection() ClockCollection {
clockColl := ClockCollection{}
for label, locStr := range locData {
timeLoc, err := time.LoadLocation(widget.sanitizeLocation(locStr.(string)))
if err != nil {
continue
}
clockColl.Clocks = append(clockColl.Clocks, NewClock(label, timeLoc))
}
clockColl.Clocks = widget.settings.locations
return clockColl
}
func (widget *Widget) sanitizeLocation(locStr string) string {
return strings.Replace(locStr, " ", "_", -1)
}

View File

@ -13,11 +13,12 @@ const (
// Settings for the cmdrunner widget
type Settings struct {
common *cfg.Common
*cfg.Common
args []string `help:"The arguments to the command, with each item as an element in an array. Example: for curl -I cisco.com, the arguments array would be ['-I', 'cisco.com']."`
cmd string `help:"The terminal command to be run, withouth the arguments. Ie: ping, whoami, curl."`
tail bool `help:"Automatically scroll to the end of the command output."`
pty bool `help:"Run the command in a pseudo-terminal. Some apps will behave differently if they feel in a terminal. For example, some apps will produce colorized output in a terminal, and non-colorized output otherwise. Default false" optional:"true"`
maxLines int `help:"Maximum number of lines kept in the buffer."`
// The dimensions of the module
@ -28,10 +29,11 @@ type Settings struct {
// NewSettingsFromYAML loads the cmdrunner portion of the WTF config
func NewSettingsFromYAML(name string, moduleConfig *config.Config, globalConfig *config.Config) *Settings {
settings := Settings{
common: cfg.NewCommonSettingsFromModule(name, defaultTitle, defaultFocusable, moduleConfig, globalConfig),
Common: cfg.NewCommonSettingsFromModule(name, defaultTitle, defaultFocusable, moduleConfig, globalConfig),
args: utils.ToStrs(moduleConfig.UList("args")),
cmd: moduleConfig.UString("cmd"),
pty: moduleConfig.UBool("pty", false),
tail: moduleConfig.UBool("tail", false),
maxLines: moduleConfig.UInt("maxLines", 256),
}

View File

@ -3,11 +3,13 @@ package cmdrunner
import (
"bytes"
"fmt"
"io"
"os"
"os/exec"
"strings"
"sync"
"github.com/creack/pty"
"github.com/rivo/tview"
"github.com/wtfutil/wtf/view"
)
@ -25,9 +27,9 @@ type Widget struct {
}
// NewWidget creates a new instance of the widget
func NewWidget(app *tview.Application, settings *Settings) *Widget {
func NewWidget(tviewApp *tview.Application, settings *Settings) *Widget {
widget := Widget{
TextWidget: view.NewTextWidget(app, settings.common),
TextWidget: view.NewTextWidget(tviewApp, nil, settings.Common),
settings: settings,
buffer: &bytes.Buffer{},
@ -121,23 +123,45 @@ func runCommandLoop(widget *Widget) {
<-widget.runChan
widget.resetBuffer()
cmd := exec.Command(widget.settings.cmd, widget.settings.args...)
cmd.Stdout = widget
cmd.Env = widget.environment()
err := cmd.Run()
// The command has exited, print any error messages
var err error
if widget.settings.pty {
err = runCommandPty(widget, cmd)
} else {
err = runCommand(widget, cmd)
}
if err != nil {
widget.m.Lock()
_, writeErr := widget.buffer.WriteString(err.Error())
if writeErr != nil {
return
}
widget.m.Unlock()
widget.handleError(err)
}
widget.redrawChan <- true
}
}
func runCommand(widget *Widget, cmd *exec.Cmd) error {
cmd.Stdout = widget
return cmd.Run()
}
func runCommandPty(widget *Widget, cmd *exec.Cmd) error {
f, err := pty.Start(cmd)
// The command has exited, print any error messages
if err != nil {
return err
}
_, err = io.Copy(widget.buffer, f)
return err
}
func (widget *Widget) handleError(err error) {
widget.m.Lock()
defer widget.m.Unlock()
_, writeErr := widget.buffer.WriteString(err.Error())
if writeErr != nil {
return
}
}
func redrawLoop(widget *Widget) {
for {
widget.Redraw(widget.content)

14
modules/covid/cases.go Normal file
View File

@ -0,0 +1,14 @@
package covid
// Cases holds the latest cases
type Cases struct {
Latest Latest `json:"latest"`
}
// Latest holds the number of global confirmed cases and deaths due to Covid
type Latest struct {
Confirmed int `json:"confirmed"`
Deaths int `json:"deaths"`
// Not currently used but holds information about the country
Locations []interface{} `json:"locations,omitempty"`
}

View File

@ -0,0 +1,24 @@
package covid
import (
"encoding/json"
"testing"
)
func Test_CasesInclude(t *testing.T) {
// The api does not seem to return the correct recovered numbers
responseBody := `{"latest":{"confirmed":3093619,"deaths":73018,"recovered":0},"locations":[]}`
latestData := Cases{}
_ = json.Unmarshal([]byte(responseBody), &latestData)
expectedConfirmed := 3093619
expectedDeaths := 73018
actualConfirmed := latestData.Latest.Confirmed
actualDeaths := latestData.Latest.Deaths
if expectedConfirmed != actualConfirmed {
t.Errorf("\nexpected: %v\n got: %v", expectedConfirmed, actualConfirmed)
}
if expectedDeaths != actualDeaths {
t.Errorf("\nexpected: %v\n got: %v", expectedDeaths, actualDeaths)
}
}

58
modules/covid/client.go Normal file
View File

@ -0,0 +1,58 @@
package covid
import (
"fmt"
"net/http"
"github.com/wtfutil/wtf/utils"
)
const covidTrackerAPIURL = "https://coronavirus-tracker-api.herokuapp.com/v2/"
// LatestCases queries the /latest endpoint, does not take any query parameters
func LatestCases() (*Cases, error) {
latestURL := covidTrackerAPIURL + "latest"
resp, err := http.Get(latestURL)
if resp.StatusCode != 200 {
return nil, fmt.Errorf(resp.Status)
}
if err != nil {
return nil, err
}
defer func() { _ = resp.Body.Close() }()
var latestGlobalCases Cases
err = utils.ParseJSON(&latestGlobalCases, resp.Body)
if err != nil {
return nil, err
}
return &latestGlobalCases, nil
}
// LatestCountryCases queries the /locations endpoint, takes a query parameter: the country code
func (widget *Widget) LatestCountryCases(countries []interface{}) ([]*Cases, error) {
countriesCovidData := []*Cases{}
for _, name := range countries {
countryURL := covidTrackerAPIURL + "locations?source=jhu&country_code=" + name.(string)
resp, err := http.Get(countryURL)
if resp.StatusCode != 200 {
return nil, fmt.Errorf(resp.Status)
}
if err != nil {
return nil, err
}
defer func() { _ = resp.Body.Close() }()
var latestCountryCases Cases
err = utils.ParseJSON(&latestCountryCases, resp.Body)
if err != nil {
return nil, err
}
// add stats for each country to the slice
countriesCovidData = append(countriesCovidData, &latestCountryCases)
}
return countriesCovidData, nil
}

31
modules/covid/settings.go Normal file
View File

@ -0,0 +1,31 @@
package covid
import (
"github.com/olebedev/config"
"github.com/wtfutil/wtf/cfg"
)
const (
defaultFocusable = false
defaultTitle = "Covid tracker"
)
// Settings is the struct for this module's settings
type Settings struct {
*cfg.Common
countries []interface{} `help:"Countries (codes) from which to retrieve stats."`
}
// NewSettingsFromYAML returns the settings from the config yaml file
func NewSettingsFromYAML(name string, ymlConfig *config.Config, globalConfig *config.Config) *Settings {
settings := Settings{
Common: cfg.NewCommonSettingsFromModule(name, defaultTitle, defaultFocusable, ymlConfig, globalConfig),
// List of countries to retrieve stats from
countries: ymlConfig.UList("countries"),
}
return &settings
}

86
modules/covid/widget.go Normal file
View File

@ -0,0 +1,86 @@
package covid
import (
"fmt"
"github.com/rivo/tview"
"github.com/wtfutil/wtf/view"
)
// Widget is the struct that defines this module widget
type Widget struct {
view.TextWidget
settings *Settings
err error
}
// NewWidget creates a new widget for this module
func NewWidget(app *tview.Application, settings *Settings) *Widget {
widget := &Widget{
TextWidget: view.NewTextWidget(app, nil, settings.Common),
settings: settings,
}
widget.View.SetScrollable(true)
return widget
}
// Refresh checks if this module widget is disabled
func (widget *Widget) Refresh() {
if widget.Disabled() {
return
}
widget.Redraw(widget.content)
}
// Render renders this module widget
func (widget *Widget) Render() {
widget.Redraw(widget.content)
}
// Display stats based on the user's locale
func (widget *Widget) displayStats(cases int) string {
prntr, err := widget.settings.LocalizedPrinter()
if err != nil {
return err.Error()
}
return prntr.Sprintf("%d", cases)
}
func (widget *Widget) content() (string, string, bool) {
title := defaultTitle
if widget.CommonSettings().Title != "" {
title = widget.CommonSettings().Title
}
cases, err := LatestCases()
var covidStats string
if err != nil {
widget.err = err
} else {
// Display global stats
covidStats = fmt.Sprintf("[%s]Global[white]\n", widget.settings.Colors.Subheading)
covidStats += fmt.Sprintf("%s: %s\n", "Confirmed", widget.displayStats(cases.Latest.Confirmed))
covidStats += fmt.Sprintf("%s: %s\n", "Deaths", widget.displayStats(cases.Latest.Deaths))
}
// Retrieve country stats if country codes are set in the config
if len(widget.settings.countries) > 0 {
countryCases, err := widget.LatestCountryCases(widget.settings.countries)
if err != nil {
widget.err = err
} else {
for i, name := range countryCases {
covidStats += fmt.Sprintf("[%s]Country[white]: %s\n", widget.settings.Colors.Subheading, widget.settings.countries[i])
covidStats += fmt.Sprintf("%s: %s\n", "Confirmed", widget.displayStats(name.Latest.Confirmed))
covidStats += fmt.Sprintf("%s: %s\n", "Deaths", widget.displayStats(name.Latest.Deaths))
}
}
}
return title, covidStats, true
}

View File

@ -32,15 +32,16 @@ type summary struct {
}
type Settings struct {
*cfg.Common
colors
common *cfg.Common
summary
}
func NewSettingsFromYAML(name string, ymlConfig *config.Config, globalConfig *config.Config) *Settings {
settings := Settings{
common: cfg.NewCommonSettingsFromModule(name, defaultTitle, defaultFocusable, ymlConfig, globalConfig),
Common: cfg.NewCommonSettingsFromModule(name, defaultTitle, defaultFocusable, ymlConfig, globalConfig),
}
settings.colors.base.name = ymlConfig.UString("colors.base.name")
@ -62,5 +63,7 @@ func NewSettingsFromYAML(name string, ymlConfig *config.Config, globalConfig *co
settings.summary.currencies[key] = currency
}
settings.SetDocumentationPath("cryptocurrencies/bittrex")
return &settings
}

View File

@ -29,9 +29,9 @@ type Widget struct {
}
// NewWidget Make new instance of widget
func NewWidget(app *tview.Application, settings *Settings) *Widget {
func NewWidget(tviewApp *tview.Application, settings *Settings) *Widget {
widget := Widget{
TextWidget: view.NewTextWidget(app, settings.common),
TextWidget: view.NewTextWidget(tviewApp, nil, settings.Common),
settings: settings,
summaryList: summaryList{},

View File

@ -17,8 +17,9 @@ type colors struct {
}
type Settings struct {
*cfg.Common
colors
common *cfg.Common
deviceToken string
displayHoldings bool
@ -27,11 +28,13 @@ type Settings struct {
func NewSettingsFromYAML(name string, ymlConfig *config.Config, globalConfig *config.Config) *Settings {
settings := Settings{
common: cfg.NewCommonSettingsFromModule(name, defaultTitle, defaultFocusable, ymlConfig, globalConfig),
Common: cfg.NewCommonSettingsFromModule(name, defaultTitle, defaultFocusable, ymlConfig, globalConfig),
deviceToken: ymlConfig.UString("device_token"),
displayHoldings: ymlConfig.UBool("displayHoldings", true),
}
settings.SetDocumentationPath("cryptocurrencies/blockfolio")
return &settings
}

View File

@ -18,9 +18,9 @@ type Widget struct {
settings *Settings
}
func NewWidget(app *tview.Application, settings *Settings) *Widget {
func NewWidget(tviewApp *tview.Application, settings *Settings) *Widget {
widget := Widget{
TextWidget: view.NewTextWidget(app, settings.common),
TextWidget: view.NewTextWidget(tviewApp, nil, settings.Common),
device_token: settings.deviceToken,
settings: settings,

View File

@ -38,15 +38,16 @@ type currency struct {
}
type Settings struct {
*cfg.Common
colors
common *cfg.Common
currencies map[string]*currency
}
func NewSettingsFromYAML(name string, ymlConfig *config.Config, globalConfig *config.Config) *Settings {
settings := Settings{
common: cfg.NewCommonSettingsFromModule(name, defaultTitle, defaultFocusable, ymlConfig, globalConfig),
Common: cfg.NewCommonSettingsFromModule(name, defaultTitle, defaultFocusable, ymlConfig, globalConfig),
}
settings.colors.from.name = ymlConfig.UString("colors.from.name")

View File

@ -137,7 +137,7 @@ func makeRequest(currency *fromCurrency) *http.Request {
tsyms += fmt.Sprintf("%s,", to.name)
}
url := fmt.Sprintf("%s?fsym=%s&tsyms=%s", baseURL, currency.name, "")
url := fmt.Sprintf("%s?fsym=%s&tsyms=%s", baseURL, currency.name, tsyms)
request, _ := http.NewRequest("GET", url, nil)
return request

View File

@ -35,8 +35,9 @@ type colors struct {
}
type Settings struct {
*cfg.Common
colors
common *cfg.Common
currencies map[string]interface{}
top map[string]interface{}
@ -50,7 +51,7 @@ func NewSettingsFromYAML(name string, ymlConfig *config.Config, globalConfig *co
top, _ := ymlConfig.Map("top")
settings := Settings{
common: cfg.NewCommonSettingsFromModule(name, defaultTitle, defaultFocusable, ymlConfig, globalConfig),
Common: cfg.NewCommonSettingsFromModule(name, defaultTitle, defaultFocusable, ymlConfig, globalConfig),
currencies: currencies,
top: top,
@ -72,5 +73,7 @@ func NewSettingsFromYAML(name string, ymlConfig *config.Config, globalConfig *co
settings.colors.top.to.field = ymlConfig.UString("colors.top.to.field")
settings.colors.top.to.value = ymlConfig.UString("colors.top.to.value")
settings.SetDocumentationPath("cryptocurrencies/cryptolive")
return &settings
}

View File

@ -39,15 +39,16 @@ type currency struct {
}
type Settings struct {
*cfg.Common
colors
common *cfg.Common
top map[string]*currency
top map[string]*currency
}
func NewSettingsFromYAML(name string, ymlConfig *config.Config, globalConfig *config.Config) *Settings {
settings := Settings{
common: cfg.NewCommonSettingsFromModule(name, defaultTitle, defaultFocusable, ymlConfig, globalConfig),
Common: cfg.NewCommonSettingsFromModule(name, defaultTitle, defaultFocusable, ymlConfig, globalConfig),
}
settings.colors.from.name = ymlConfig.UString("colors.from.name")

View File

@ -20,9 +20,9 @@ type Widget struct {
}
// NewWidget Make new instance of widget
func NewWidget(app *tview.Application, settings *Settings) *Widget {
func NewWidget(tviewApp *tview.Application, settings *Settings) *Widget {
widget := Widget{
TextWidget: view.NewTextWidget(app, settings.common),
TextWidget: view.NewTextWidget(tviewApp, nil, settings.Common),
priceWidget: price.NewWidget(settings.priceSettings),
toplistWidget: toplist.NewWidget(settings.toplistSettings),

View File

@ -5,7 +5,7 @@ import (
datadog "github.com/zorkian/go-datadog-api"
)
// Monitors returns a list of newrelic monitors
// Monitors returns a list of Datadog monitors
func (widget *Widget) Monitors() ([]datadog.Monitor, error) {
client := datadog.NewClient(
widget.settings.apiKey,

View File

@ -5,7 +5,8 @@ import (
)
func (widget *Widget) initializeKeyboardControls() {
widget.InitializeCommonControls(widget.Refresh)
widget.InitializeHelpTextKeyboardControl(widget.ShowHelp)
widget.InitializeRefreshKeyboardControl(widget.Refresh)
widget.SetKeyboardChar("j", widget.Next, "Select next item")
widget.SetKeyboardChar("k", widget.Prev, "Select previous item")

View File

@ -13,7 +13,7 @@ const (
)
type Settings struct {
common *cfg.Common
*cfg.Common
apiKey string `help:"Your Datadog API key."`
applicationKey string `help:"Your Datadog Application key."`
@ -23,7 +23,7 @@ type Settings struct {
func NewSettingsFromYAML(name string, ymlConfig *config.Config, globalConfig *config.Config) *Settings {
settings := Settings{
common: cfg.NewCommonSettingsFromModule(name, defaultTitle, defaultFocusable, ymlConfig, globalConfig),
Common: cfg.NewCommonSettingsFromModule(name, defaultTitle, defaultFocusable, ymlConfig, globalConfig),
apiKey: ymlConfig.UString("apiKey", ymlConfig.UString("apikey", os.Getenv("WTF_DATADOG_API_KEY"))),
applicationKey: ymlConfig.UString("applicationKey", os.Getenv("WTF_DATADOG_APPLICATION_KEY")),

View File

@ -10,7 +10,6 @@ import (
)
type Widget struct {
view.KeyboardWidget
view.ScrollableWidget
monitors []datadog.Monitor
@ -18,19 +17,15 @@ type Widget struct {
err error
}
func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *Widget {
func NewWidget(tviewApp *tview.Application, pages *tview.Pages, settings *Settings) *Widget {
widget := Widget{
KeyboardWidget: view.NewKeyboardWidget(app, pages, settings.common),
ScrollableWidget: view.NewScrollableWidget(app, settings.common),
ScrollableWidget: view.NewScrollableWidget(tviewApp, pages, settings.Common),
settings: settings,
}
widget.SetRenderFunction(widget.Render)
widget.initializeKeyboardControls()
widget.View.SetInputCapture(widget.InputCapture)
widget.KeyboardWidget.SetView(widget.View)
return &widget
}
@ -66,10 +61,6 @@ func (widget *Widget) Render() {
widget.Redraw(widget.content)
}
func (widget *Widget) HelpText() string {
return widget.KeyboardWidget.HelpText()
}
/* -------------------- Unexported Functions -------------------- */
func (widget *Widget) content() (string, string, bool) {
@ -87,7 +78,7 @@ func (widget *Widget) content() (string, string, bool) {
" %s\n",
fmt.Sprintf(
"[%s]Triggered Monitors[white]",
widget.settings.common.Colors.Subheading,
widget.settings.Colors.Subheading,
),
)
for idx, triggeredMonitor := range triggeredMonitors {

View File

@ -3,7 +3,8 @@ package devto
import "github.com/gdamore/tcell"
func (widget *Widget) initializeKeyboardControls() {
widget.InitializeCommonControls(widget.Refresh)
widget.InitializeHelpTextKeyboardControl(widget.ShowHelp)
widget.InitializeRefreshKeyboardControl(widget.Refresh)
widget.SetKeyboardChar("d", widget.Next, "Select next item")
widget.SetKeyboardChar("a", widget.Prev, "Select previous item")

View File

@ -13,7 +13,7 @@ const (
// Settings defines the configuration options for this module
type Settings struct {
common *cfg.Common
*cfg.Common
numberOfArticles int `help:"Number of stories to show. Default is 10" optional:"true"`
contentTag string `help:"List articles from a specific tag. Default is empty" optional:"true"`
@ -24,7 +24,8 @@ type Settings struct {
// NewSettingsFromYAML creates and returns an instance of Settings with configuration options populated
func NewSettingsFromYAML(name string, yamlConfig *config.Config, globalConfig *config.Config) *Settings {
settings := Settings{
common: cfg.NewCommonSettingsFromModule(name, defaultTitle, defaultFocusable, yamlConfig, globalConfig),
Common: cfg.NewCommonSettingsFromModule(name, defaultTitle, defaultFocusable, yamlConfig, globalConfig),
numberOfArticles: yamlConfig.UInt("numberOfArticles", 10),
contentTag: yamlConfig.UString("contentTag", ""),
contentUsername: yamlConfig.UString("contentUsername", ""),

View File

@ -12,17 +12,16 @@ import (
)
type Widget struct {
view.KeyboardWidget
view.ScrollableWidget
articles []devto.ListedArticle
settings *Settings
err error
}
func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *Widget {
func NewWidget(tviewApp *tview.Application, pages *tview.Pages, settings *Settings) *Widget {
widget := &Widget{
KeyboardWidget: view.NewKeyboardWidget(app, pages, settings.common),
ScrollableWidget: view.NewScrollableWidget(app, settings.common),
ScrollableWidget: view.NewScrollableWidget(tviewApp, pages, settings.Common),
settings: settings,
}
@ -30,9 +29,6 @@ func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *
widget.SetRenderFunction(widget.Render)
widget.View.SetScrollable(true)
widget.initializeKeyboardControls()
widget.View.SetInputCapture(widget.InputCapture)
widget.KeyboardWidget.SetView(widget.View)
return widget
}

View File

@ -12,7 +12,7 @@ const (
// Settings defines the configuration properties for this module
type Settings struct {
common *cfg.Common
*cfg.Common
color string `help:"The color of the clock."`
font string `help:"The font of the clock." values:"bigfont or digitalfont"`
@ -23,7 +23,7 @@ type Settings struct {
// NewSettingsFromYAML creates a new settings instance from a YAML config block
func NewSettingsFromYAML(name string, ymlConfig *config.Config, globalConfig *config.Config) *Settings {
settings := Settings{
common: cfg.NewCommonSettingsFromModule(name, defaultTitle, defaultFocusable, ymlConfig, globalConfig),
Common: cfg.NewCommonSettingsFromModule(name, defaultTitle, defaultFocusable, ymlConfig, globalConfig),
color: ymlConfig.UString("color"),
font: ymlConfig.UString("font"),

View File

@ -9,16 +9,14 @@ import (
type Widget struct {
view.TextWidget
app *tview.Application
settings *Settings
}
// NewWidget creates a new widget using settings
func NewWidget(app *tview.Application, settings *Settings) *Widget {
func NewWidget(tviewApp *tview.Application, settings *Settings) *Widget {
widget := Widget{
TextWidget: view.NewTextWidget(app, settings.common),
TextWidget: view.NewTextWidget(tviewApp, nil, settings.Common),
app: app,
settings: settings,
}

View File

@ -2,33 +2,60 @@ package digitalocean
import (
"fmt"
"strings"
"github.com/wtfutil/wtf/utils"
)
const maxColWidth = 12
func (widget *Widget) content() (string, string, bool) {
columnSet := widget.settings.columns
title := widget.CommonSettings().Title
if widget.err != nil {
return title, widget.err.Error(), true
}
str := fmt.Sprintf(
" [%s]Droplets\n\n",
widget.settings.common.Colors.Subheading,
)
if len(columnSet) < 1 {
return title, " no columns defined", false
}
str := fmt.Sprintf(" [::b][%s]", widget.settings.Colors.Subheading)
for _, colName := range columnSet {
truncName := utils.Truncate(colName, maxColWidth, false)
str += fmt.Sprintf("%-12s", truncName)
}
str += "\n"
for idx, droplet := range widget.droplets {
dropletName := droplet.Name
// This defines the formatting for the row, one tab-seperated string for each defined column
fmtStr := " [%s]"
row := fmt.Sprintf(
"[%s] %-8s %-24s %s",
for range columnSet {
fmtStr += "%-12s"
}
vals := []interface{}{
widget.RowColor(idx),
droplet.Status,
dropletName,
utils.Truncate(strings.Join(droplet.Tags, ","), 24, true),
)
}
// Dynamically access the droplet to get the requested columns values
for _, colName := range columnSet {
val, err := droplet.StringValueForProperty(colName)
if err != nil {
val = "???"
}
truncVal := utils.Truncate(val, maxColWidth, false)
vals = append(vals, truncVal)
}
// And format, print, and color the row
row := fmt.Sprintf(fmtStr, vals...)
str += utils.HighlightableHelper(widget.View, row, idx, 33)
}

View File

@ -0,0 +1,80 @@
package digitalocean
import (
"fmt"
"reflect"
"strings"
"github.com/digitalocean/godo"
"github.com/wtfutil/wtf/utils"
)
// Droplet represents WTF's view of a DigitalOcean droplet
type Droplet struct {
godo.Droplet
Image Image
Region Region
}
// Image represents WTF's view of a DigitalOcean droplet image
type Image struct {
godo.Image
utils.Reflective
}
// Region represents WTF's view of a DigitalOcean region
type Region struct {
godo.Region
utils.Reflective
}
// NewDroplet creates and returns an instance of Droplet
func NewDroplet(doDroplet godo.Droplet) *Droplet {
droplet := &Droplet{
doDroplet,
Image{
*doDroplet.Image,
utils.Reflective{},
},
Region{
*doDroplet.Region,
utils.Reflective{},
},
}
return droplet
}
/* -------------------- Exported Functions -------------------- */
// StringValueForProperty returns a string value for the given column
func (drop *Droplet) StringValueForProperty(propName string) (string, error) {
var strVal string
var err error
// Figure out if we should forward this property to a sub-object
// Lets us support "Region.Name" column definitions
split := strings.Split(propName, ".")
switch split[0] {
case "Image":
strVal, err = drop.Image.StringValueForProperty(split[1])
case "Region":
strVal, err = drop.Region.StringValueForProperty(split[1])
default:
v := reflect.ValueOf(drop)
refVal := reflect.Indirect(v).FieldByName(propName)
if !refVal.IsValid() {
err = fmt.Errorf("invalid property name: %s", propName)
} else {
strVal = fmt.Sprintf("%v", refVal)
}
}
return strVal, err
}

View File

@ -5,13 +5,12 @@ import (
"strconv"
"strings"
"github.com/digitalocean/godo"
"github.com/wtfutil/wtf/utils"
"github.com/wtfutil/wtf/view"
)
type dropletPropertiesTable struct {
droplet *godo.Droplet
droplet *Droplet
propertyMap map[string]string
colWidth0 int
@ -20,7 +19,7 @@ type dropletPropertiesTable struct {
}
// newDropletPropertiesTable creates and returns an instance of DropletPropertiesTable
func newDropletPropertiesTable(droplet *godo.Droplet) *dropletPropertiesTable {
func newDropletPropertiesTable(droplet *Droplet) *dropletPropertiesTable {
propTable := &dropletPropertiesTable{
droplet: droplet,

View File

@ -3,7 +3,8 @@ package digitalocean
import "github.com/gdamore/tcell"
func (widget *Widget) initializeKeyboardControls() {
widget.InitializeCommonControls(widget.Refresh)
widget.InitializeHelpTextKeyboardControl(widget.ShowHelp)
widget.InitializeRefreshKeyboardControl(widget.Refresh)
widget.SetKeyboardChar("?", widget.showInfo, "Show info about the selected droplet")

View File

@ -5,6 +5,7 @@ import (
"github.com/olebedev/config"
"github.com/wtfutil/wtf/cfg"
"github.com/wtfutil/wtf/utils"
"github.com/wtfutil/wtf/wtf"
)
@ -13,21 +14,31 @@ const (
defaultTitle = "DigitalOcean"
)
// defaultColumns defines the default set of columns to display in the widget
// This can be over-ridden in the cofig by explicitly defining a set of columns
var defaultColumns = []interface{}{
"Name",
"Status",
"Region.Slug",
}
// Settings defines the configuration properties for this module
type Settings struct {
common *cfg.Common
*cfg.Common
apiKey string `help:"Your DigitalOcean API key."`
dateFormat string `help:"The format to display dates and times in."`
apiKey string `help:"Your DigitalOcean API key."`
columns []string `help:"A list of the droplet properties to display."`
dateFormat string `help:"The format to display dates and times in."`
}
// NewSettingsFromYAML creates a new settings instance from a YAML config block
func NewSettingsFromYAML(name string, ymlConfig *config.Config, globalConfig *config.Config) *Settings {
settings := Settings{
common: cfg.NewCommonSettingsFromModule(name, defaultTitle, defaultFocusable, ymlConfig, globalConfig),
Common: cfg.NewCommonSettingsFromModule(name, defaultTitle, defaultFocusable, ymlConfig, globalConfig),
apiKey: ymlConfig.UString("apiKey", ymlConfig.UString("apikey", os.Getenv("WTF_DIGITALOCEAN_API_KEY"))),
columns: utils.ToStrs(ymlConfig.UList("columns", defaultColumns)),
dateFormat: ymlConfig.UString("dateFormat", wtf.DateFormat),
}

View File

@ -30,34 +30,31 @@ func (t *tokenSource) Token() (*oauth2.Token, error) {
// Widget is the container for droplet data
type Widget struct {
view.KeyboardWidget
view.ScrollableWidget
app *tview.Application
client *godo.Client
droplets []godo.Droplet
droplets []*Droplet
pages *tview.Pages
settings *Settings
err error
err error
}
// NewWidget creates a new instance of a widget
func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *Widget {
func NewWidget(tviewApp *tview.Application, pages *tview.Pages, settings *Settings) *Widget {
widget := Widget{
KeyboardWidget: view.NewKeyboardWidget(app, pages, settings.common),
ScrollableWidget: view.NewScrollableWidget(app, settings.common),
ScrollableWidget: view.NewScrollableWidget(tviewApp, pages, settings.Common),
app: app,
app: tviewApp,
pages: pages,
settings: settings,
}
widget.initializeKeyboardControls()
widget.View.SetInputCapture(widget.InputCapture)
widget.View.SetScrollable(true)
widget.KeyboardWidget.SetView(widget.View)
widget.SetRenderFunction(widget.display)
widget.createClient()
@ -78,11 +75,6 @@ func (widget *Widget) Fetch() error {
return err
}
// HelpText returns the help text for this widget
func (widget *Widget) HelpText() string {
return widget.KeyboardWidget.HelpText()
}
// Next selects the next item in the list
func (widget *Widget) Next() {
widget.ScrollableWidget.Next()
@ -127,7 +119,7 @@ func (widget *Widget) createClient() {
// currentDroplet returns the currently-selected droplet, if there is one
// Returns nil if no droplet is selected
func (widget *Widget) currentDroplet() *godo.Droplet {
func (widget *Widget) currentDroplet() *Droplet {
if len(widget.droplets) == 0 {
return nil
}
@ -136,21 +128,24 @@ func (widget *Widget) currentDroplet() *godo.Droplet {
return nil
}
return &widget.droplets[widget.Selected]
return widget.droplets[widget.Selected]
}
// dropletsFetch uses the DigitalOcean API to fetch information about all the available droplets
func (widget *Widget) dropletsFetch() ([]godo.Droplet, error) {
dropletList := []godo.Droplet{}
func (widget *Widget) dropletsFetch() ([]*Droplet, error) {
dropletList := []*Droplet{}
opts := &godo.ListOptions{}
for {
droplets, resp, err := widget.client.Droplets.List(context.Background(), opts)
doDroplets, resp, err := widget.client.Droplets.List(context.Background(), opts)
if err != nil {
return dropletList, err
}
dropletList = append(dropletList, droplets...)
for _, doDroplet := range doDroplets {
droplet := NewDroplet(doDroplet)
dropletList = append(dropletList, droplet)
}
if resp.Links == nil || resp.Links.IsLastPage() {
break

View File

@ -41,13 +41,13 @@ func (widget *Widget) getSystemInfo() string {
}{
{
name: "name:",
value: fmt.Sprintf("[%s]%s", widget.settings.common.Colors.RowTheme.EvenForeground, info.Name),
value: fmt.Sprintf("[%s]%s", widget.settings.Colors.RowTheme.EvenForeground, info.Name),
}, {
name: "version:",
value: fmt.Sprintf("[%s]%s", widget.settings.common.Colors.RowTheme.EvenForeground, info.ServerVersion),
value: fmt.Sprintf("[%s]%s", widget.settings.Colors.RowTheme.EvenForeground, info.ServerVersion),
}, {
name: "root:",
value: fmt.Sprintf("[%s]%s", widget.settings.common.Colors.RowTheme.EvenForeground, info.DockerRootDir),
value: fmt.Sprintf("[%s]%s", widget.settings.Colors.RowTheme.EvenForeground, info.DockerRootDir),
},
{
name: "containers:",
@ -57,15 +57,15 @@ func (widget *Widget) getSystemInfo() string {
},
{
name: "images:",
value: fmt.Sprintf("[%s]%d", widget.settings.common.Colors.RowTheme.EvenForeground, info.Images),
value: fmt.Sprintf("[%s]%d", widget.settings.Colors.RowTheme.EvenForeground, info.Images),
},
{
name: "volumes:",
value: fmt.Sprintf("[%s]%v", widget.settings.common.Colors.RowTheme.EvenForeground, len(diskUsage.Volumes)),
value: fmt.Sprintf("[%s]%v", widget.settings.Colors.RowTheme.EvenForeground, len(diskUsage.Volumes)),
},
{
name: "memory limit:",
value: fmt.Sprintf("[%s]%s", widget.settings.common.Colors.RowTheme.EvenForeground, humanize.Bytes(uint64(info.MemTotal))),
value: fmt.Sprintf("[%s]%s", widget.settings.Colors.RowTheme.EvenForeground, humanize.Bytes(uint64(info.MemTotal))),
},
{
name: "disk usage:",
@ -76,19 +76,19 @@ func (widget *Widget) getSystemInfo() string {
[%s]* [::b]total: [%s]%s[::-]
`,
widget.settings.labelColor,
widget.settings.common.Colors.RowTheme.EvenForeground,
widget.settings.Colors.RowTheme.EvenForeground,
humanize.Bytes(uint64(duContainer)),
widget.settings.labelColor,
widget.settings.common.Colors.RowTheme.EvenForeground,
widget.settings.Colors.RowTheme.EvenForeground,
humanize.Bytes(uint64(duImg)),
widget.settings.labelColor,
widget.settings.common.Colors.RowTheme.EvenForeground,
widget.settings.Colors.RowTheme.EvenForeground,
humanize.Bytes(uint64(duVol)),
widget.settings.labelColor,
widget.settings.common.Colors.RowTheme.EvenForeground,
widget.settings.Colors.RowTheme.EvenForeground,
humanize.Bytes(uint64(duContainer+duImg+duVol))),
},
}

View File

@ -12,14 +12,15 @@ const (
// Settings defines the configuration options for this module
type Settings struct {
common *cfg.Common
*cfg.Common
labelColor string
}
// NewSettingsFromYAML creates and returns an instance of Settings with configuration options populated
func NewSettingsFromYAML(name string, ymlConfig *config.Config, globalConfig *config.Config) *Settings {
settings := Settings{
common: cfg.NewCommonSettingsFromModule(name, defaultTitle, defaultFocusable, ymlConfig, globalConfig),
Common: cfg.NewCommonSettingsFromModule(name, defaultTitle, defaultFocusable, ymlConfig, globalConfig),
labelColor: ymlConfig.UString("labelColor", "white"),
}

View File

@ -16,9 +16,9 @@ type Widget struct {
displayBuffer string
}
func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *Widget {
func NewWidget(tviewApp *tview.Application, pages *tview.Pages, settings *Settings) *Widget {
widget := Widget{
TextWidget: view.NewTextWidget(app, settings.common),
TextWidget: view.NewTextWidget(tviewApp, pages, settings.Common),
settings: settings,
}
@ -56,11 +56,11 @@ func (widget *Widget) refreshDisplayBuffer() {
widget.displayBuffer = ""
widget.displayBuffer += fmt.Sprintf("[%s] System[white]\n", widget.settings.common.Colors.Subheading)
widget.displayBuffer += fmt.Sprintf("[%s] System[white]\n", widget.settings.Colors.Subheading)
widget.displayBuffer += widget.getSystemInfo()
widget.displayBuffer += "\n"
widget.displayBuffer += fmt.Sprintf("[%s] Containers[white]\n", widget.settings.common.Colors.Subheading)
widget.displayBuffer += fmt.Sprintf("[%s] Containers[white]\n", widget.settings.Colors.Subheading)
widget.displayBuffer += widget.getContainerStates()
}

View File

@ -13,7 +13,7 @@ const (
// Settings defines the configuration properties for this module
type Settings struct {
common *cfg.Common
*cfg.Common
precision int `help:"How many decimal places to display." optional:"true"`
@ -24,7 +24,7 @@ type Settings struct {
// NewSettingsFromYAML creates a new settings instance from a YAML config block
func NewSettingsFromYAML(name string, ymlConfig *config.Config, globalConfig *config.Config) *Settings {
settings := Settings{
common: cfg.NewCommonSettingsFromModule(name, defaultTitle, defaultFocusable, ymlConfig, globalConfig),
Common: cfg.NewCommonSettingsFromModule(name, defaultTitle, defaultFocusable, ymlConfig, globalConfig),
precision: ymlConfig.UInt("precision", 7),

View File

@ -3,6 +3,7 @@ package exchangerates
import (
"fmt"
"regexp"
"sort"
"github.com/rivo/tview"
"github.com/wtfutil/wtf/view"
@ -17,9 +18,9 @@ type Widget struct {
err error
}
func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *Widget {
func NewWidget(tviewApp *tview.Application, pages *tview.Pages, settings *Settings) *Widget {
widget := Widget{
ScrollableWidget: view.NewScrollableWidget(app, settings.common),
ScrollableWidget: view.NewScrollableWidget(tviewApp, pages, settings.Common),
settings: settings,
}
@ -56,15 +57,26 @@ func (widget *Widget) content() (string, string, bool) {
return widget.CommonSettings().Title, widget.err.Error(), false
}
// Sort the bases alphabetically to ensure consistent display ordering
bases := []string{}
for base := range widget.settings.rates {
bases = append(bases, base)
}
sort.Strings(bases)
out := ""
idx := 0
for base, rates := range widget.settings.rates {
for idx, base := range bases {
rates := widget.settings.rates[base]
rowColor := widget.CommonSettings().RowColor(idx)
for _, cur := range rates {
rate := widget.rates[base][cur]
out += fmt.Sprintf(
"[%s]1 %s = %s %s[white]\n",
widget.CommonSettings().RowColor(idx),
rowColor,
base,
widget.formatConversionRate(rate),
cur,

Some files were not shown because too many files have changed in this diff Show More