mirror of
				https://github.com/taigrr/wtf
				synced 2025-01-18 04:03:14 -08:00 
			
		
		
		
	Properly scope Config to the wtf package and remove it as a dependency from everywhere else
This commit is contained in:
		
							parent
							
								
									abedee0ce0
								
							
						
					
					
						commit
						66b69471d0
					
				| @ -3,13 +3,9 @@ package bamboohr | |||||||
| import ( | import ( | ||||||
| 	"fmt" | 	"fmt" | ||||||
| 
 | 
 | ||||||
| 	"github.com/olebedev/config" |  | ||||||
| 	"github.com/senorprogrammer/wtf/wtf" | 	"github.com/senorprogrammer/wtf/wtf" | ||||||
| ) | ) | ||||||
| 
 | 
 | ||||||
| // Config is a pointer to the global config object |  | ||||||
| var Config *config.Config |  | ||||||
| 
 |  | ||||||
| type Widget struct { | type Widget struct { | ||||||
| 	wtf.TextWidget | 	wtf.TextWidget | ||||||
| } | } | ||||||
|  | |||||||
| @ -8,13 +8,9 @@ import ( | |||||||
| 	"math/rand" | 	"math/rand" | ||||||
| 	"time" | 	"time" | ||||||
| 
 | 
 | ||||||
| 	"github.com/olebedev/config" |  | ||||||
| 	"github.com/senorprogrammer/wtf/wtf" | 	"github.com/senorprogrammer/wtf/wtf" | ||||||
| ) | ) | ||||||
| 
 | 
 | ||||||
| // Config is a pointer to the global config object |  | ||||||
| var Config *config.Config |  | ||||||
| 
 |  | ||||||
| var started = false | var started = false | ||||||
| var ok = true | var ok = true | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -1,10 +1,10 @@ | |||||||
| package circleci | package circleci | ||||||
| 
 | 
 | ||||||
| type Build struct { | type Build struct { | ||||||
| 	AuthorEmail        string            `json:"author_email"` | 	AuthorEmail string `json:"author_email"` | ||||||
| 	AuthorName         string            `json:"author_name"` | 	AuthorName  string `json:"author_name"` | ||||||
| 	Branch             string            `json:"branch"` | 	Branch      string `json:"branch"` | ||||||
| 	BuildNum           int               `json:"build_num"` | 	BuildNum    int    `json:"build_num"` | ||||||
| 	Reponame           string            `json:"reponame"` | 	Reponame    string `json:"reponame"` | ||||||
| 	Status             string            `json:"status"` | 	Status      string `json:"status"` | ||||||
| } | } | ||||||
|  | |||||||
| @ -2,13 +2,9 @@ package circleci | |||||||
| 
 | 
 | ||||||
| import ( | import ( | ||||||
| 	"fmt" | 	"fmt" | ||||||
| 	"github.com/olebedev/config" |  | ||||||
| 	"github.com/senorprogrammer/wtf/wtf" | 	"github.com/senorprogrammer/wtf/wtf" | ||||||
| ) | ) | ||||||
| 
 | 
 | ||||||
| // Config is a pointer to the global config object |  | ||||||
| var Config *config.Config |  | ||||||
| 
 |  | ||||||
| type Widget struct { | type Widget struct { | ||||||
| 	wtf.TextWidget | 	wtf.TextWidget | ||||||
| } | } | ||||||
| @ -65,19 +61,15 @@ func (widget *Widget) contentFrom(builds []*Build) string { | |||||||
| 	return str | 	return str | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| func buildColor(b *Build) string { | func buildColor(build *Build) string { | ||||||
| 	var color string | 	switch build.Status { | ||||||
| 
 |  | ||||||
| 	switch b.Status { |  | ||||||
| 	case "failed": | 	case "failed": | ||||||
| 		color = "red" | 		return "red" | ||||||
| 	case "running": | 	case "running": | ||||||
| 		color = "yellow" | 		return "yellow" | ||||||
| 	case "success": | 	case "success": | ||||||
| 		color = "green" | 		return "green" | ||||||
| 	default: | 	default: | ||||||
| 		color = "white" | 		return "white" | ||||||
| 	} | 	} | ||||||
| 
 |  | ||||||
| 	return color |  | ||||||
| } | } | ||||||
|  | |||||||
| @ -3,6 +3,8 @@ package clocks | |||||||
| import ( | import ( | ||||||
| 	"sort" | 	"sort" | ||||||
| 	"time" | 	"time" | ||||||
|  | 
 | ||||||
|  | 	"github.com/senorprogrammer/wtf/wtf" | ||||||
| ) | ) | ||||||
| 
 | 
 | ||||||
| type ClockCollection struct { | type ClockCollection struct { | ||||||
| @ -10,7 +12,7 @@ type ClockCollection struct { | |||||||
| } | } | ||||||
| 
 | 
 | ||||||
| func (clocks *ClockCollection) Sorted() []Clock { | func (clocks *ClockCollection) Sorted() []Clock { | ||||||
| 	if "chronological" == Config.UString("wtf.mods.clocks.sort", "alphabetical") { | 	if "chronological" == wtf.Config.UString("wtf.mods.clocks.sort", "alphabetical") { | ||||||
| 		clocks.SortedChronologically() | 		clocks.SortedChronologically() | ||||||
| 	} else { | 	} else { | ||||||
| 		clocks.SortedAlphabetically() | 		clocks.SortedAlphabetically() | ||||||
|  | |||||||
| @ -3,13 +3,9 @@ package clocks | |||||||
| import ( | import ( | ||||||
| 	"time" | 	"time" | ||||||
| 
 | 
 | ||||||
| 	"github.com/olebedev/config" |  | ||||||
| 	"github.com/senorprogrammer/wtf/wtf" | 	"github.com/senorprogrammer/wtf/wtf" | ||||||
| ) | ) | ||||||
| 
 | 
 | ||||||
| // Config is a pointer to the global config object |  | ||||||
| var Config *config.Config |  | ||||||
| 
 |  | ||||||
| type Widget struct { | type Widget struct { | ||||||
| 	wtf.TextWidget | 	wtf.TextWidget | ||||||
| 
 | 
 | ||||||
| @ -21,7 +17,7 @@ func NewWidget() *Widget { | |||||||
| 		TextWidget: wtf.NewTextWidget(" World Clocks ", "clocks", false), | 		TextWidget: wtf.NewTextWidget(" World Clocks ", "clocks", false), | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	widget.clockColl = widget.buildClockCollection(Config.UMap("wtf.mods.clocks.locations")) | 	widget.clockColl = widget.buildClockCollection(wtf.Config.UMap("wtf.mods.clocks.locations")) | ||||||
| 
 | 
 | ||||||
| 	return &widget | 	return &widget | ||||||
| } | } | ||||||
|  | |||||||
| @ -5,13 +5,9 @@ import ( | |||||||
| 	"os/exec" | 	"os/exec" | ||||||
| 	"strings" | 	"strings" | ||||||
| 
 | 
 | ||||||
| 	"github.com/olebedev/config" |  | ||||||
| 	"github.com/senorprogrammer/wtf/wtf" | 	"github.com/senorprogrammer/wtf/wtf" | ||||||
| ) | ) | ||||||
| 
 | 
 | ||||||
| // Config is a pointer to the global config object |  | ||||||
| var Config *config.Config |  | ||||||
| 
 |  | ||||||
| type Widget struct { | type Widget struct { | ||||||
| 	wtf.TextWidget | 	wtf.TextWidget | ||||||
| 
 | 
 | ||||||
| @ -24,8 +20,8 @@ func NewWidget() *Widget { | |||||||
| 	widget := Widget{ | 	widget := Widget{ | ||||||
| 		TextWidget: wtf.NewTextWidget(" CmdRunner ", "cmdrunner", false), | 		TextWidget: wtf.NewTextWidget(" CmdRunner ", "cmdrunner", false), | ||||||
| 
 | 
 | ||||||
| 		args: wtf.ToStrs(Config.UList("wtf.mods.cmdrunner.args")), | 		args: wtf.ToStrs(wtf.Config.UList("wtf.mods.cmdrunner.args")), | ||||||
| 		cmd:  Config.UString("wtf.mods.cmdrunner.cmd"), | 		cmd:  wtf.Config.UString("wtf.mods.cmdrunner.cmd"), | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	widget.View.SetWrap(true) | 	widget.View.SetWrap(true) | ||||||
| @ -37,7 +33,7 @@ func (widget *Widget) Refresh() { | |||||||
| 	widget.UpdateRefreshedAt() | 	widget.UpdateRefreshedAt() | ||||||
| 	widget.execute() | 	widget.execute() | ||||||
| 
 | 
 | ||||||
| 	title := Config.UString("wtf.mods.cmdrunner.title", widget.String()) | 	title := wtf.Config.UString("wtf.mods.cmdrunner.title", widget.String()) | ||||||
| 	widget.View.SetTitle(fmt.Sprintf("%s", title)) | 	widget.View.SetTitle(fmt.Sprintf("%s", title)) | ||||||
| 
 | 
 | ||||||
| 	widget.View.SetText(fmt.Sprintf("%s", widget.result)) | 	widget.View.SetText(fmt.Sprintf("%s", widget.result)) | ||||||
|  | |||||||
| @ -7,13 +7,9 @@ import ( | |||||||
| 
 | 
 | ||||||
| 	"net/http" | 	"net/http" | ||||||
| 
 | 
 | ||||||
| 	"github.com/olebedev/config" |  | ||||||
| 	"github.com/senorprogrammer/wtf/wtf" | 	"github.com/senorprogrammer/wtf/wtf" | ||||||
| ) | ) | ||||||
| 
 | 
 | ||||||
| // Config is a pointer to the global config object |  | ||||||
| var Config *config.Config |  | ||||||
| 
 |  | ||||||
| type TextColors struct { | type TextColors struct { | ||||||
| 	base struct { | 	base struct { | ||||||
| 		name        string | 		name        string | ||||||
| @ -55,17 +51,17 @@ func NewWidget() *Widget { | |||||||
| } | } | ||||||
| 
 | 
 | ||||||
| func (widget *Widget) config() { | func (widget *Widget) config() { | ||||||
| 	widget.TextColors.base.name = Config.UString("wtf.mods.bittrex.colors.base.name", "red") | 	widget.TextColors.base.name = wtf.Config.UString("wtf.mods.bittrex.colors.base.name", "red") | ||||||
| 	widget.TextColors.base.displayName = Config.UString("wtf.mods.bittrex.colors.base.displayName", "grey") | 	widget.TextColors.base.displayName = wtf.Config.UString("wtf.mods.bittrex.colors.base.displayName", "grey") | ||||||
| 	widget.TextColors.market.name = Config.UString("wtf.mods.bittrex.colors.market.name", "red") | 	widget.TextColors.market.name = wtf.Config.UString("wtf.mods.bittrex.colors.market.name", "red") | ||||||
| 	widget.TextColors.market.field = Config.UString("wtf.mods.bittrex.colors.market.field", "coral") | 	widget.TextColors.market.field = wtf.Config.UString("wtf.mods.bittrex.colors.market.field", "coral") | ||||||
| 	widget.TextColors.market.value = Config.UString("wtf.mods.bittrex.colors.market.value", "white") | 	widget.TextColors.market.value = wtf.Config.UString("wtf.mods.bittrex.colors.market.value", "white") | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| func (widget *Widget) setSummaryList() { | func (widget *Widget) setSummaryList() { | ||||||
| 	sCurrencies, _ := Config.Map("wtf.mods.bittrex.summary") | 	sCurrencies, _ := wtf.Config.Map("wtf.mods.bittrex.summary") | ||||||
| 	for baseCurrencyName := range sCurrencies { | 	for baseCurrencyName := range sCurrencies { | ||||||
| 		displayName, _ := Config.String("wtf.mods.bittrex.summary." + baseCurrencyName + ".displayName") | 		displayName, _ := wtf.Config.String("wtf.mods.bittrex.summary." + baseCurrencyName + ".displayName") | ||||||
| 		mCurrencyList := makeSummaryMarketList(baseCurrencyName) | 		mCurrencyList := makeSummaryMarketList(baseCurrencyName) | ||||||
| 		widget.summaryList.addSummaryItem(baseCurrencyName, displayName, mCurrencyList) | 		widget.summaryList.addSummaryItem(baseCurrencyName, displayName, mCurrencyList) | ||||||
| 	} | 	} | ||||||
| @ -74,7 +70,7 @@ func (widget *Widget) setSummaryList() { | |||||||
| func makeSummaryMarketList(currencyName string) []*mCurrency { | func makeSummaryMarketList(currencyName string) []*mCurrency { | ||||||
| 	mCurrencyList := []*mCurrency{} | 	mCurrencyList := []*mCurrency{} | ||||||
| 
 | 
 | ||||||
| 	configMarketList, _ := Config.List("wtf.mods.bittrex.summary." + currencyName + ".market") | 	configMarketList, _ := wtf.Config.List("wtf.mods.bittrex.summary." + currencyName + ".market") | ||||||
| 	for _, mCurrencyName := range configMarketList { | 	for _, mCurrencyName := range configMarketList { | ||||||
| 		mCurrencyList = append(mCurrencyList, makeMarketCurrency(mCurrencyName.(string))) | 		mCurrencyList = append(mCurrencyList, makeMarketCurrency(mCurrencyName.(string))) | ||||||
| 	} | 	} | ||||||
|  | |||||||
| @ -7,14 +7,10 @@ import ( | |||||||
| 	"log" | 	"log" | ||||||
| 	"net/http" | 	"net/http" | ||||||
| 
 | 
 | ||||||
| 	"github.com/olebedev/config" |  | ||||||
| 	"github.com/rivo/tview" | 	"github.com/rivo/tview" | ||||||
| 	"github.com/senorprogrammer/wtf/wtf" | 	"github.com/senorprogrammer/wtf/wtf" | ||||||
| ) | ) | ||||||
| 
 | 
 | ||||||
| // Config is a pointer to the global config object |  | ||||||
| var Config *config.Config |  | ||||||
| 
 |  | ||||||
| type Widget struct { | type Widget struct { | ||||||
| 	wtf.TextWidget | 	wtf.TextWidget | ||||||
| 
 | 
 | ||||||
| @ -25,7 +21,7 @@ type Widget struct { | |||||||
| func NewWidget(app *tview.Application, pages *tview.Pages) *Widget { | func NewWidget(app *tview.Application, pages *tview.Pages) *Widget { | ||||||
| 	widget := Widget{ | 	widget := Widget{ | ||||||
| 		TextWidget:   wtf.NewTextWidget(" Blockfolio ", "blockfolio", false), | 		TextWidget:   wtf.NewTextWidget(" Blockfolio ", "blockfolio", false), | ||||||
| 		device_token: Config.UString("wtf.mods.blockfolio.device_token"), | 		device_token: wtf.Config.UString("wtf.mods.blockfolio.device_token"), | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	return &widget | 	return &widget | ||||||
| @ -47,10 +43,10 @@ func (widget *Widget) Refresh() { | |||||||
| /* -------------------- Unexported Functions -------------------- */ | /* -------------------- Unexported Functions -------------------- */ | ||||||
| func contentFrom(positions *AllPositionsResponse) string { | func contentFrom(positions *AllPositionsResponse) string { | ||||||
| 	res := "" | 	res := "" | ||||||
| 	colorName := Config.UString("wtf.mods.blockfolio.colors.name") | 	colorName := wtf.Config.UString("wtf.mods.blockfolio.colors.name") | ||||||
| 	colorGrows := Config.UString("wtf.mods.blockfolio.colors.grows") | 	colorGrows := wtf.Config.UString("wtf.mods.blockfolio.colors.grows") | ||||||
| 	colorDrop := Config.UString("wtf.mods.blockfolio.colors.drop") | 	colorDrop := wtf.Config.UString("wtf.mods.blockfolio.colors.drop") | ||||||
| 	displayHoldings := Config.UBool("wtf.mods.blockfolio.displayHoldings") | 	displayHoldings := wtf.Config.UBool("wtf.mods.blockfolio.displayHoldings") | ||||||
| 	var totalFiat float32 | 	var totalFiat float32 | ||||||
| 	totalFiat = 0.0 | 	totalFiat = 0.0 | ||||||
| 	for i := 0; i < len(positions.PositionList); i++ { | 	for i := 0; i < len(positions.PositionList); i++ { | ||||||
|  | |||||||
| @ -6,13 +6,9 @@ import ( | |||||||
| 	"net/http" | 	"net/http" | ||||||
| 	"time" | 	"time" | ||||||
| 
 | 
 | ||||||
| 	"github.com/olebedev/config" |  | ||||||
| 	"github.com/senorprogrammer/wtf/wtf" | 	"github.com/senorprogrammer/wtf/wtf" | ||||||
| ) | ) | ||||||
| 
 | 
 | ||||||
| // Config is a pointer to the global config object |  | ||||||
| var Config *config.Config |  | ||||||
| 
 |  | ||||||
| var baseURL = "https://min-api.cryptocompare.com/data/price" | var baseURL = "https://min-api.cryptocompare.com/data/price" | ||||||
| var ok = true | var ok = true | ||||||
| 
 | 
 | ||||||
| @ -56,10 +52,10 @@ func (widget *Widget) Refresh() { | |||||||
| func (widget *Widget) display() { | func (widget *Widget) display() { | ||||||
| 	str := "" | 	str := "" | ||||||
| 	var ( | 	var ( | ||||||
| 		fromNameColor        = Config.UString("wtf.mods.cryptolive.colors.from.name", "coral") | 		fromNameColor        = wtf.Config.UString("wtf.mods.cryptolive.colors.from.name", "coral") | ||||||
| 		fromDisplayNameColor = Config.UString("wtf.mods.cryptolive.colors.from.displayName", "grey") | 		fromDisplayNameColor = wtf.Config.UString("wtf.mods.cryptolive.colors.from.displayName", "grey") | ||||||
| 		toNameColor          = Config.UString("wtf.mods.cryptolive.colors.to.name", "white") | 		toNameColor          = wtf.Config.UString("wtf.mods.cryptolive.colors.to.name", "white") | ||||||
| 		toPriceColor         = Config.UString("wtf.mods.cryptolive.colors.to.price", "green") | 		toPriceColor         = wtf.Config.UString("wtf.mods.cryptolive.colors.to.price", "green") | ||||||
| 	) | 	) | ||||||
| 	for _, item := range widget.list.items { | 	for _, item := range widget.list.items { | ||||||
| 		str += fmt.Sprintf(" [%s]%s[%s] (%s)\n", fromNameColor, item.displayName, fromDisplayNameColor, item.name) | 		str += fmt.Sprintf(" [%s]%s[%s] (%s)\n", fromNameColor, item.displayName, fromDisplayNameColor, item.name) | ||||||
| @ -73,7 +69,7 @@ func (widget *Widget) display() { | |||||||
| } | } | ||||||
| 
 | 
 | ||||||
| func getToList(fromName string) []*toCurrency { | func getToList(fromName string) []*toCurrency { | ||||||
| 	toNames, _ := Config.List("wtf.mods.cryptolive.currencies." + fromName + ".to") | 	toNames, _ := wtf.Config.List("wtf.mods.cryptolive.currencies." + fromName + ".to") | ||||||
| 
 | 
 | ||||||
| 	var toList []*toCurrency | 	var toList []*toCurrency | ||||||
| 
 | 
 | ||||||
| @ -88,12 +84,12 @@ func getToList(fromName string) []*toCurrency { | |||||||
| } | } | ||||||
| 
 | 
 | ||||||
| func (widget *Widget) setList() { | func (widget *Widget) setList() { | ||||||
| 	currenciesMap, _ := Config.Map("wtf.mods.cryptolive.currencies") | 	currenciesMap, _ := wtf.Config.Map("wtf.mods.cryptolive.currencies") | ||||||
| 
 | 
 | ||||||
| 	widget.list = &list{} | 	widget.list = &list{} | ||||||
| 
 | 
 | ||||||
| 	for currency := range currenciesMap { | 	for currency := range currenciesMap { | ||||||
| 		displayName, _ := Config.String("wtf.mods.cryptolive.currencies." + currency + ".displayName") | 		displayName, _ := wtf.Config.String("wtf.mods.cryptolive.currencies." + currency + ".displayName") | ||||||
| 		toList := getToList(currency) | 		toList := getToList(currency) | ||||||
| 		widget.list.addItem(currency, displayName, toList) | 		widget.list.addItem(currency, displayName, toList) | ||||||
| 	} | 	} | ||||||
|  | |||||||
| @ -29,7 +29,7 @@ import ( | |||||||
| func Fetch() (*calendar.Events, error) { | func Fetch() (*calendar.Events, error) { | ||||||
| 	ctx := context.Background() | 	ctx := context.Background() | ||||||
| 
 | 
 | ||||||
| 	secretPath, _ := wtf.ExpandHomeDir(Config.UString("wtf.mods.gcal.secretFile")) | 	secretPath, _ := wtf.ExpandHomeDir(wtf.Config.UString("wtf.mods.gcal.secretFile")) | ||||||
| 
 | 
 | ||||||
| 	b, err := ioutil.ReadFile(secretPath) | 	b, err := ioutil.ReadFile(secretPath) | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| @ -48,7 +48,7 @@ func Fetch() (*calendar.Events, error) { | |||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	startTime := fromMidnight().Format(time.RFC3339) | 	startTime := fromMidnight().Format(time.RFC3339) | ||||||
| 	eventLimit := int64(Config.UInt("wtf.mods.gcal.eventCount", 10)) | 	eventLimit := int64(wtf.Config.UInt("wtf.mods.gcal.eventCount", 10)) | ||||||
| 	events, err := srv.Events.List("primary").ShowDeleted(false).SingleEvents(true).TimeMin(startTime).MaxResults(eventLimit).OrderBy("startTime").Do() | 	events, err := srv.Events.List("primary").ShowDeleted(false).SingleEvents(true).TimeMin(startTime).MaxResults(eventLimit).OrderBy("startTime").Do() | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		return nil, err | 		return nil, err | ||||||
|  | |||||||
| @ -6,14 +6,10 @@ import ( | |||||||
| 	"strings" | 	"strings" | ||||||
| 	"time" | 	"time" | ||||||
| 
 | 
 | ||||||
| 	"github.com/olebedev/config" |  | ||||||
| 	"github.com/senorprogrammer/wtf/wtf" | 	"github.com/senorprogrammer/wtf/wtf" | ||||||
| 	"google.golang.org/api/calendar/v3" | 	"google.golang.org/api/calendar/v3" | ||||||
| ) | ) | ||||||
| 
 | 
 | ||||||
| // Config is a pointer to the global config object |  | ||||||
| var Config *config.Config |  | ||||||
| 
 |  | ||||||
| type Widget struct { | type Widget struct { | ||||||
| 	wtf.TextWidget | 	wtf.TextWidget | ||||||
| } | } | ||||||
| @ -105,10 +101,10 @@ func (widget *Widget) dayDivider(event, prevEvent *calendar.Event) string { | |||||||
| } | } | ||||||
| 
 | 
 | ||||||
| func (widget *Widget) descriptionColor(event *calendar.Event) string { | func (widget *Widget) descriptionColor(event *calendar.Event) string { | ||||||
| 	color := Config.UString("wtf.mods.gcal.colors.description", "white") | 	color := wtf.Config.UString("wtf.mods.gcal.colors.description", "white") | ||||||
| 
 | 
 | ||||||
| 	if widget.eventIsPast(event) { | 	if widget.eventIsPast(event) { | ||||||
| 		color = Config.UString("wtf.mods.gcal.colors.past", "gray") | 		color = wtf.Config.UString("wtf.mods.gcal.colors.past", "gray") | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	return color | 	return color | ||||||
| @ -120,13 +116,13 @@ func (widget *Widget) eventSummary(event *calendar.Event, conflict bool) string | |||||||
| 	if widget.eventIsNow(event) { | 	if widget.eventIsNow(event) { | ||||||
| 		summary = fmt.Sprintf( | 		summary = fmt.Sprintf( | ||||||
| 			"%s %s", | 			"%s %s", | ||||||
| 			Config.UString("wtf.mods.gcal.currentIcon", "🔸"), | 			wtf.Config.UString("wtf.mods.gcal.currentIcon", "🔸"), | ||||||
| 			event.Summary, | 			event.Summary, | ||||||
| 		) | 		) | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	if conflict { | 	if conflict { | ||||||
| 		return fmt.Sprintf("%s %s", Config.UString("wtf.mods.gcal.conflictIcon", "🚨"), summary) | 		return fmt.Sprintf("%s %s", wtf.Config.UString("wtf.mods.gcal.conflictIcon", "🚨"), summary) | ||||||
| 	} else { | 	} else { | ||||||
| 		return summary | 		return summary | ||||||
| 	} | 	} | ||||||
| @ -151,9 +147,9 @@ func (widget *Widget) eventIsPast(event *calendar.Event) bool { | |||||||
| } | } | ||||||
| 
 | 
 | ||||||
| func (widget *Widget) titleColor(event *calendar.Event) string { | func (widget *Widget) titleColor(event *calendar.Event) string { | ||||||
| 	color := Config.UString("wtf.mods.gcal.colors.title", "white") | 	color := wtf.Config.UString("wtf.mods.gcal.colors.title", "white") | ||||||
| 
 | 
 | ||||||
| 	for _, untypedArr := range Config.UList("wtf.mods.gcal.colors.highlights") { | 	for _, untypedArr := range wtf.Config.UList("wtf.mods.gcal.colors.highlights") { | ||||||
| 		highlightElements := wtf.ToStrs(untypedArr.([]interface{})) | 		highlightElements := wtf.ToStrs(untypedArr.([]interface{})) | ||||||
| 
 | 
 | ||||||
| 		match, _ := regexp.MatchString( | 		match, _ := regexp.MatchString( | ||||||
| @ -167,14 +163,14 @@ func (widget *Widget) titleColor(event *calendar.Event) string { | |||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	if widget.eventIsPast(event) { | 	if widget.eventIsPast(event) { | ||||||
| 		color = Config.UString("wtf.mods.gcal.colors.past", "gray") | 		color = wtf.Config.UString("wtf.mods.gcal.colors.past", "gray") | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	return color | 	return color | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| func (widget *Widget) location(event *calendar.Event) string { | func (widget *Widget) location(event *calendar.Event) string { | ||||||
| 	if Config.UBool("wtf.mods.gcal.displayLocation", true) == false { | 	if wtf.Config.UBool("wtf.mods.gcal.displayLocation", true) == false { | ||||||
| 		return "" | 		return "" | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| @ -190,14 +186,14 @@ func (widget *Widget) location(event *calendar.Event) string { | |||||||
| } | } | ||||||
| 
 | 
 | ||||||
| func (widget *Widget) responseIcon(event *calendar.Event) string { | func (widget *Widget) responseIcon(event *calendar.Event) string { | ||||||
| 	if false == Config.UBool("wtf.mods.gcal.displayResponseStatus", true) { | 	if false == wtf.Config.UBool("wtf.mods.gcal.displayResponseStatus", true) { | ||||||
| 		return "" | 		return "" | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	response := "" | 	response := "" | ||||||
| 
 | 
 | ||||||
| 	for _, attendee := range event.Attendees { | 	for _, attendee := range event.Attendees { | ||||||
| 		if attendee.Email == Config.UString("wtf.mods.gcal.email") { | 		if attendee.Email == wtf.Config.UString("wtf.mods.gcal.email") { | ||||||
| 			response = attendee.ResponseStatus | 			response = attendee.ResponseStatus | ||||||
| 			break | 			break | ||||||
| 		} | 		} | ||||||
|  | |||||||
| @ -50,12 +50,12 @@ func (repo *GitRepo) changedFiles() []string { | |||||||
| } | } | ||||||
| 
 | 
 | ||||||
| func (repo *GitRepo) commits() []string { | func (repo *GitRepo) commits() []string { | ||||||
| 	numStr := fmt.Sprintf("-n %d", Config.UInt("wtf.mods.git.commitCount", 10)) | 	numStr := fmt.Sprintf("-n %d", wtf.Config.UInt("wtf.mods.git.commitCount", 10)) | ||||||
| 
 | 
 | ||||||
| 	dateFormat := Config.UString("wtf.mods.git.dateFormat", "%b %d, %Y") | 	dateFormat := wtf.Config.UString("wtf.mods.git.dateFormat", "%b %d, %Y") | ||||||
| 	dateStr := fmt.Sprintf("--date=format:\"%s\"", dateFormat) | 	dateStr := fmt.Sprintf("--date=format:\"%s\"", dateFormat) | ||||||
| 
 | 
 | ||||||
| 	commitFormat := Config.UString("wtf.mods.git.commitFormat", "[forestgreen]%h [white]%s [grey]%an on %cd[white]") | 	commitFormat := wtf.Config.UString("wtf.mods.git.commitFormat", "[forestgreen]%h [white]%s [grey]%an on %cd[white]") | ||||||
| 	commitStr := fmt.Sprintf("--pretty=format:\"%s\"", commitFormat) | 	commitStr := fmt.Sprintf("--pretty=format:\"%s\"", commitFormat) | ||||||
| 
 | 
 | ||||||
| 	arg := []string{repo.gitDir(), repo.workTree(), "log", dateStr, numStr, commitStr} | 	arg := []string{repo.gitDir(), repo.workTree(), "log", dateStr, numStr, commitStr} | ||||||
|  | |||||||
| @ -2,14 +2,10 @@ package git | |||||||
| 
 | 
 | ||||||
| import ( | import ( | ||||||
| 	"github.com/gdamore/tcell" | 	"github.com/gdamore/tcell" | ||||||
| 	"github.com/olebedev/config" |  | ||||||
| 	"github.com/rivo/tview" | 	"github.com/rivo/tview" | ||||||
| 	"github.com/senorprogrammer/wtf/wtf" | 	"github.com/senorprogrammer/wtf/wtf" | ||||||
| ) | ) | ||||||
| 
 | 
 | ||||||
| // Config is a pointer to the global config object |  | ||||||
| var Config *config.Config |  | ||||||
| 
 |  | ||||||
| const HelpText = ` | const HelpText = ` | ||||||
|   Keyboard commands for Git: |   Keyboard commands for Git: | ||||||
| 
 | 
 | ||||||
| @ -53,7 +49,7 @@ func NewWidget(app *tview.Application, pages *tview.Pages) *Widget { | |||||||
| /* -------------------- Exported Functions -------------------- */ | /* -------------------- Exported Functions -------------------- */ | ||||||
| 
 | 
 | ||||||
| func (widget *Widget) Refresh() { | func (widget *Widget) Refresh() { | ||||||
| 	repoPaths := wtf.ToStrs(Config.UList("wtf.mods.git.repositories")) | 	repoPaths := wtf.ToStrs(wtf.Config.UList("wtf.mods.git.repositories")) | ||||||
| 
 | 
 | ||||||
| 	widget.UpdateRefreshedAt() | 	widget.UpdateRefreshedAt() | ||||||
| 	widget.Data = widget.gitRepos(repoPaths) | 	widget.Data = widget.gitRepos(repoPaths) | ||||||
|  | |||||||
| @ -21,10 +21,10 @@ func (widget *Widget) display() { | |||||||
| 	str = str + widget.displayStats(repo) | 	str = str + widget.displayStats(repo) | ||||||
| 	str = str + "\n" | 	str = str + "\n" | ||||||
| 	str = str + " [red]Open Review Requests[white]\n" | 	str = str + " [red]Open Review Requests[white]\n" | ||||||
| 	str = str + widget.displayMyReviewRequests(repo, Config.UString("wtf.mods.github.username")) | 	str = str + widget.displayMyReviewRequests(repo, wtf.Config.UString("wtf.mods.github.username")) | ||||||
| 	str = str + "\n" | 	str = str + "\n" | ||||||
| 	str = str + " [red]My Pull Requests[white]\n" | 	str = str + " [red]My Pull Requests[white]\n" | ||||||
| 	str = str + widget.displayMyPullRequests(repo, Config.UString("wtf.mods.github.username")) | 	str = str + widget.displayMyPullRequests(repo, wtf.Config.UString("wtf.mods.github.username")) | ||||||
| 
 | 
 | ||||||
| 	widget.View.SetText(str) | 	widget.View.SetText(str) | ||||||
| } | } | ||||||
|  | |||||||
| @ -2,14 +2,10 @@ package github | |||||||
| 
 | 
 | ||||||
| import ( | import ( | ||||||
| 	"github.com/gdamore/tcell" | 	"github.com/gdamore/tcell" | ||||||
| 	"github.com/olebedev/config" |  | ||||||
| 	"github.com/rivo/tview" | 	"github.com/rivo/tview" | ||||||
| 	"github.com/senorprogrammer/wtf/wtf" | 	"github.com/senorprogrammer/wtf/wtf" | ||||||
| ) | ) | ||||||
| 
 | 
 | ||||||
| // Config is a pointer to the global config object |  | ||||||
| var Config *config.Config |  | ||||||
| 
 |  | ||||||
| const HelpText = ` | const HelpText = ` | ||||||
|   Keyboard commands for Github: |   Keyboard commands for Github: | ||||||
| 
 | 
 | ||||||
| @ -41,7 +37,7 @@ func NewWidget(app *tview.Application, pages *tview.Pages) *Widget { | |||||||
| 		pages: pages, | 		pages: pages, | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	widget.GithubRepos = widget.buildRepoCollection(Config.UMap("wtf.mods.github.repositories")) | 	widget.GithubRepos = widget.buildRepoCollection(wtf.Config.UMap("wtf.mods.github.repositories")) | ||||||
| 
 | 
 | ||||||
| 	widget.View.SetInputCapture(widget.keyboardIntercept) | 	widget.View.SetInputCapture(widget.keyboardIntercept) | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -21,10 +21,10 @@ func (widget *Widget) display() { | |||||||
| 	str = str + widget.displayStats(project) | 	str = str + widget.displayStats(project) | ||||||
| 	str = str + "\n" | 	str = str + "\n" | ||||||
| 	str = str + " [red]Open Approval Requests[white]\n" | 	str = str + " [red]Open Approval Requests[white]\n" | ||||||
| 	str = str + widget.displayMyApprovalRequests(project, Config.UString("wtf.mods.gitlab.username")) | 	str = str + widget.displayMyApprovalRequests(project, wtf.Config.UString("wtf.mods.gitlab.username")) | ||||||
| 	str = str + "\n" | 	str = str + "\n" | ||||||
| 	str = str + " [red]My Merge Requests[white]\n" | 	str = str + " [red]My Merge Requests[white]\n" | ||||||
| 	str = str + widget.displayMyMergeRequests(project, Config.UString("wtf.mods.gitlab.username")) | 	str = str + widget.displayMyMergeRequests(project, wtf.Config.UString("wtf.mods.gitlab.username")) | ||||||
| 
 | 
 | ||||||
| 	widget.View.SetText(str) | 	widget.View.SetText(str) | ||||||
| } | } | ||||||
|  | |||||||
| @ -4,15 +4,11 @@ import ( | |||||||
| 	"os" | 	"os" | ||||||
| 
 | 
 | ||||||
| 	"github.com/gdamore/tcell" | 	"github.com/gdamore/tcell" | ||||||
| 	"github.com/olebedev/config" |  | ||||||
| 	"github.com/rivo/tview" | 	"github.com/rivo/tview" | ||||||
| 	"github.com/senorprogrammer/wtf/wtf" | 	"github.com/senorprogrammer/wtf/wtf" | ||||||
| 	glb "github.com/xanzy/go-gitlab" | 	glb "github.com/xanzy/go-gitlab" | ||||||
| ) | ) | ||||||
| 
 | 
 | ||||||
| // Config is a pointer to the global config object |  | ||||||
| var Config *config.Config |  | ||||||
| 
 |  | ||||||
| const HelpText = ` | const HelpText = ` | ||||||
|   Keyboard commands for Gitlab: |   Keyboard commands for Gitlab: | ||||||
| 
 | 
 | ||||||
| @ -39,7 +35,7 @@ type Widget struct { | |||||||
| 
 | 
 | ||||||
| func NewWidget(app *tview.Application, pages *tview.Pages) *Widget { | func NewWidget(app *tview.Application, pages *tview.Pages) *Widget { | ||||||
| 	apiKey := os.Getenv("WTF_GITLAB_TOKEN") | 	apiKey := os.Getenv("WTF_GITLAB_TOKEN") | ||||||
| 	baseURL := Config.UString("wtf.mods.gitlab.domain") | 	baseURL := wtf.Config.UString("wtf.mods.gitlab.domain") | ||||||
| 	gitlab := glb.NewClient(nil, apiKey) | 	gitlab := glb.NewClient(nil, apiKey) | ||||||
| 	if baseURL != "" { | 	if baseURL != "" { | ||||||
| 		gitlab.SetBaseURL(baseURL) | 		gitlab.SetBaseURL(baseURL) | ||||||
| @ -56,7 +52,7 @@ func NewWidget(app *tview.Application, pages *tview.Pages) *Widget { | |||||||
| 		Idx: 0, | 		Idx: 0, | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	widget.GitlabProjects = widget.buildProjectCollection(Config.UMap("wtf.mods.gitlab.projects")) | 	widget.GitlabProjects = widget.buildProjectCollection(wtf.Config.UMap("wtf.mods.gitlab.projects")) | ||||||
| 
 | 
 | ||||||
| 	widget.View.SetInputCapture(widget.keyboardIntercept) | 	widget.View.SetInputCapture(widget.keyboardIntercept) | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -29,7 +29,7 @@ import ( | |||||||
| func Fetch() ([]*sheets.ValueRange, error) { | func Fetch() ([]*sheets.ValueRange, error) { | ||||||
| 	ctx := context.Background() | 	ctx := context.Background() | ||||||
| 
 | 
 | ||||||
| 	secretPath, _ := wtf.ExpandHomeDir(Config.UString("wtf.mods.gspreadsheets.secretFile")) | 	secretPath, _ := wtf.ExpandHomeDir(wtf.Config.UString("wtf.mods.gspreadsheets.secretFile")) | ||||||
| 
 | 
 | ||||||
| 	b, err := ioutil.ReadFile(secretPath) | 	b, err := ioutil.ReadFile(secretPath) | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| @ -51,8 +51,8 @@ func Fetch() ([]*sheets.ValueRange, error) { | |||||||
| 		return nil, err | 		return nil, err | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	cells := wtf.ToStrs(Config.UList("wtf.mods.gspreadsheets.cells.addresses")) | 	cells := wtf.ToStrs(wtf.Config.UList("wtf.mods.gspreadsheets.cells.addresses")) | ||||||
| 	documentId := Config.UString("wtf.mods.gspreadsheets.sheetId") | 	documentId := wtf.Config.UString("wtf.mods.gspreadsheets.sheetId") | ||||||
| 	addresses := strings.Join(cells[:], ";") | 	addresses := strings.Join(cells[:], ";") | ||||||
| 
 | 
 | ||||||
| 	responses := make([]*sheets.ValueRange, len(cells)) | 	responses := make([]*sheets.ValueRange, len(cells)) | ||||||
|  | |||||||
| @ -3,14 +3,10 @@ package gspreadsheets | |||||||
| import ( | import ( | ||||||
| 	"fmt" | 	"fmt" | ||||||
| 
 | 
 | ||||||
| 	"github.com/olebedev/config" |  | ||||||
| 	"github.com/senorprogrammer/wtf/wtf" | 	"github.com/senorprogrammer/wtf/wtf" | ||||||
| 	sheets "google.golang.org/api/sheets/v4" | 	sheets "google.golang.org/api/sheets/v4" | ||||||
| ) | ) | ||||||
| 
 | 
 | ||||||
| // Config is a pointer to the global config object |  | ||||||
| var Config *config.Config |  | ||||||
| 
 |  | ||||||
| type Widget struct { | type Widget struct { | ||||||
| 	wtf.TextWidget | 	wtf.TextWidget | ||||||
| } | } | ||||||
| @ -40,10 +36,10 @@ func (widget *Widget) contentFrom(valueRanges []*sheets.ValueRange) string { | |||||||
| 		return "error 1" | 		return "error 1" | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	valuesColor := Config.UString("wtf.mods.gspreadsheets.colors.values", "green") | 	valuesColor := wtf.Config.UString("wtf.mods.gspreadsheets.colors.values", "green") | ||||||
| 	res := "" | 	res := "" | ||||||
| 
 | 
 | ||||||
| 	cells := wtf.ToStrs(Config.UList("wtf.mods.gspreadsheets.cells.names")) | 	cells := wtf.ToStrs(wtf.Config.UList("wtf.mods.gspreadsheets.cells.names")) | ||||||
| 	for i := 0; i < len(valueRanges); i++ { | 	for i := 0; i < len(valueRanges); i++ { | ||||||
| 		res = res + fmt.Sprintf("%s\t[%s]%s\n", cells[i], valuesColor, valueRanges[i].Values[0][0]) | 		res = res + fmt.Sprintf("%s\t[%s]%s\n", cells[i], valuesColor, valueRanges[i].Values[0][0]) | ||||||
| 	} | 	} | ||||||
|  | |||||||
| @ -9,13 +9,9 @@ import ( | |||||||
| 
 | 
 | ||||||
| 	"bytes" | 	"bytes" | ||||||
| 
 | 
 | ||||||
| 	"github.com/olebedev/config" |  | ||||||
| 	"github.com/senorprogrammer/wtf/wtf" | 	"github.com/senorprogrammer/wtf/wtf" | ||||||
| ) | ) | ||||||
| 
 | 
 | ||||||
| // Config is a pointer to the global config object |  | ||||||
| var Config *config.Config |  | ||||||
| 
 |  | ||||||
| // Widget widget struct | // Widget widget struct | ||||||
| type Widget struct { | type Widget struct { | ||||||
| 	wtf.TextWidget | 	wtf.TextWidget | ||||||
| @ -87,7 +83,7 @@ func (widget *Widget) ipinfo() { | |||||||
| 
 | 
 | ||||||
| // read module configs | // read module configs | ||||||
| func (widget *Widget) config() { | func (widget *Widget) config() { | ||||||
| 	nameColor, valueColor := Config.UString("wtf.mods.ipinfo.colors.name", "red"), Config.UString("wtf.mods.ipinfo.colors.value", "white") | 	nameColor, valueColor := wtf.Config.UString("wtf.mods.ipinfo.colors.name", "red"), wtf.Config.UString("wtf.mods.ipinfo.colors.value", "white") | ||||||
| 	widget.colors.name = nameColor | 	widget.colors.name = nameColor | ||||||
| 	widget.colors.value = valueColor | 	widget.colors.value = valueColor | ||||||
| } | } | ||||||
|  | |||||||
| @ -8,13 +8,9 @@ import ( | |||||||
| 
 | 
 | ||||||
| 	"bytes" | 	"bytes" | ||||||
| 
 | 
 | ||||||
| 	"github.com/olebedev/config" |  | ||||||
| 	"github.com/senorprogrammer/wtf/wtf" | 	"github.com/senorprogrammer/wtf/wtf" | ||||||
| ) | ) | ||||||
| 
 | 
 | ||||||
| // Config is a pointer to the global config object |  | ||||||
| var Config *config.Config |  | ||||||
| 
 |  | ||||||
| type Widget struct { | type Widget struct { | ||||||
| 	wtf.TextWidget | 	wtf.TextWidget | ||||||
| 	result string | 	result string | ||||||
| @ -82,7 +78,7 @@ func (widget *Widget) ipinfo() { | |||||||
| 
 | 
 | ||||||
| // read module configs | // read module configs | ||||||
| func (widget *Widget) config() { | func (widget *Widget) config() { | ||||||
| 	nameColor, valueColor := Config.UString("wtf.mods.ipinfo.colors.name", "red"), Config.UString("wtf.mods.ipinfo.colors.value", "white") | 	nameColor, valueColor := wtf.Config.UString("wtf.mods.ipinfo.colors.name", "red"), wtf.Config.UString("wtf.mods.ipinfo.colors.value", "white") | ||||||
| 	widget.colors.name = nameColor | 	widget.colors.name = nameColor | ||||||
| 	widget.colors.value = valueColor | 	widget.colors.value = valueColor | ||||||
| } | } | ||||||
|  | |||||||
| @ -1,10 +1,10 @@ | |||||||
| package jenkins | package jenkins | ||||||
| 
 | 
 | ||||||
| type View struct { | type View struct { | ||||||
| 	Class    string   `json:"_class"` | 	Class       string   `json:"_class"` | ||||||
| 	Description string	`json:"description"` | 	Description string   `json:"description"` | ||||||
| 	Jobs       []Job `json:"jobs"` | 	Jobs        []Job    `json:"jobs"` | ||||||
| 	Name      string   `json:"name"` | 	Name        string   `json:"name"` | ||||||
| 	Property  []string `json:"property"` | 	Property    []string `json:"property"` | ||||||
| 	url    string `json:"url"` | 	url         string   `json:"url"` | ||||||
| } | } | ||||||
|  | |||||||
| @ -2,14 +2,10 @@ package jenkins | |||||||
| 
 | 
 | ||||||
| import ( | import ( | ||||||
| 	"fmt" | 	"fmt" | ||||||
| 	"github.com/olebedev/config" |  | ||||||
| 	"github.com/senorprogrammer/wtf/wtf" | 	"github.com/senorprogrammer/wtf/wtf" | ||||||
| 	"os" | 	"os" | ||||||
| ) | ) | ||||||
| 
 | 
 | ||||||
| // Config is a pointer to the global config object |  | ||||||
| var Config *config.Config |  | ||||||
| 
 |  | ||||||
| type Widget struct { | type Widget struct { | ||||||
| 	wtf.TextWidget | 	wtf.TextWidget | ||||||
| } | } | ||||||
| @ -29,8 +25,11 @@ func (widget *Widget) Refresh() { | |||||||
| 		return | 		return | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	view, err := Create(Config.UString("wtf.mods.jenkins.url"), | 	view, err := Create( | ||||||
| 		Config.UString("wtf.mods.jenkins.user"), os.Getenv("WTF_JENKINS_API_KEY")) | 		wtf.Config.UString("wtf.mods.jenkins.url"), | ||||||
|  | 		wtf.Config.UString("wtf.mods.jenkins.user"), | ||||||
|  | 		os.Getenv("WTF_JENKINS_API_KEY"), | ||||||
|  | 	) | ||||||
| 
 | 
 | ||||||
| 	widget.UpdateRefreshedAt() | 	widget.UpdateRefreshedAt() | ||||||
| 	widget.View.Clear() | 	widget.View.Clear() | ||||||
| @ -54,7 +53,7 @@ func (widget *Widget) Refresh() { | |||||||
| /* -------------------- Unexported Functions -------------------- */ | /* -------------------- Unexported Functions -------------------- */ | ||||||
| 
 | 
 | ||||||
| func (widget *Widget) contentFrom(view *View) string { | func (widget *Widget) contentFrom(view *View) string { | ||||||
| 	str := fmt.Sprintf(" [red]%s[white]\n", view.Name); | 	str := fmt.Sprintf(" [red]%s[white]\n", view.Name) | ||||||
| 
 | 
 | ||||||
| 	for _, job := range view.Jobs { | 	for _, job := range view.Jobs { | ||||||
| 		str = str + fmt.Sprintf( | 		str = str + fmt.Sprintf( | ||||||
|  | |||||||
| @ -11,6 +11,8 @@ import ( | |||||||
| 	"net/url" | 	"net/url" | ||||||
| 	"os" | 	"os" | ||||||
| 	"strings" | 	"strings" | ||||||
|  | 
 | ||||||
|  | 	"github.com/senorprogrammer/wtf/wtf" | ||||||
| ) | ) | ||||||
| 
 | 
 | ||||||
| func IssuesFor(username string, projects []string, jql string) (*SearchResult, error) { | func IssuesFor(username string, projects []string, jql string) (*SearchResult, error) { | ||||||
| @ -53,21 +55,21 @@ func buildJql(key string, value string) string { | |||||||
| /* -------------------- Unexported Functions -------------------- */ | /* -------------------- Unexported Functions -------------------- */ | ||||||
| 
 | 
 | ||||||
| func jiraRequest(path string) (*http.Response, error) { | func jiraRequest(path string) (*http.Response, error) { | ||||||
| 	url := fmt.Sprintf("%s%s", Config.UString("wtf.mods.jira.domain"), path) | 	url := fmt.Sprintf("%s%s", wtf.Config.UString("wtf.mods.jira.domain"), path) | ||||||
| 
 | 
 | ||||||
| 	req, err := http.NewRequest("GET", url, nil) | 	req, err := http.NewRequest("GET", url, nil) | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		return nil, err | 		return nil, err | ||||||
| 	} | 	} | ||||||
| 	req.SetBasicAuth(Config.UString("wtf.mods.jira.email"), os.Getenv("WTF_JIRA_API_KEY")) | 	req.SetBasicAuth(wtf.Config.UString("wtf.mods.jira.email"), os.Getenv("WTF_JIRA_API_KEY")) | ||||||
| 
 | 
 | ||||||
| 	verifyServerCertificate := Config.UBool("wtf.mods.jira.verifyServerCertificate", true) | 	verifyServerCertificate := wtf.Config.UBool("wtf.mods.jira.verifyServerCertificate", true) | ||||||
| 	httpClient := &http.Client{Transport: &http.Transport{ | 	httpClient := &http.Client{Transport: &http.Transport{ | ||||||
|             TLSClientConfig: &tls.Config{ | 		TLSClientConfig: &tls.Config{ | ||||||
|                 InsecureSkipVerify: !verifyServerCertificate, | 			InsecureSkipVerify: !verifyServerCertificate, | ||||||
|             }, | 		}, | ||||||
|         }, | 	}, | ||||||
|     } | 	} | ||||||
| 	resp, err := httpClient.Do(req) | 	resp, err := httpClient.Do(req) | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		return nil, err | 		return nil, err | ||||||
|  | |||||||
| @ -3,13 +3,9 @@ package jira | |||||||
| import ( | import ( | ||||||
| 	"fmt" | 	"fmt" | ||||||
| 
 | 
 | ||||||
| 	"github.com/olebedev/config" |  | ||||||
| 	"github.com/senorprogrammer/wtf/wtf" | 	"github.com/senorprogrammer/wtf/wtf" | ||||||
| ) | ) | ||||||
| 
 | 
 | ||||||
| // Config is a pointer to the global config object |  | ||||||
| var Config *config.Config |  | ||||||
| 
 |  | ||||||
| type Widget struct { | type Widget struct { | ||||||
| 	wtf.TextWidget | 	wtf.TextWidget | ||||||
| } | } | ||||||
| @ -25,7 +21,11 @@ func NewWidget() *Widget { | |||||||
| /* -------------------- Exported Functions -------------------- */ | /* -------------------- Exported Functions -------------------- */ | ||||||
| 
 | 
 | ||||||
| func (widget *Widget) Refresh() { | func (widget *Widget) Refresh() { | ||||||
| 	searchResult, err := IssuesFor(Config.UString("wtf.mods.jira.username"), getProjects(), Config.UString("wtf.mods.jira.jql", "")) | 	searchResult, err := IssuesFor( | ||||||
|  | 		wtf.Config.UString("wtf.mods.jira.username"), | ||||||
|  | 		getProjects(), | ||||||
|  | 		wtf.Config.UString("wtf.mods.jira.jql", ""), | ||||||
|  | 	) | ||||||
| 
 | 
 | ||||||
| 	widget.UpdateRefreshedAt() | 	widget.UpdateRefreshedAt() | ||||||
| 
 | 
 | ||||||
| @ -39,7 +39,7 @@ func (widget *Widget) Refresh() { | |||||||
| 			fmt.Sprintf( | 			fmt.Sprintf( | ||||||
| 				"%s- [green]%s[white]", | 				"%s- [green]%s[white]", | ||||||
| 				widget.Name, | 				widget.Name, | ||||||
| 				Config.UString("wtf.mods.jira.project"), | 				wtf.Config.UString("wtf.mods.jira.project"), | ||||||
| 			), | 			), | ||||||
| 		) | 		) | ||||||
| 		widget.View.SetText(fmt.Sprintf("%s", widget.contentFrom(searchResult))) | 		widget.View.SetText(fmt.Sprintf("%s", widget.contentFrom(searchResult))) | ||||||
| @ -85,12 +85,12 @@ func (widget *Widget) issueTypeColor(issue *Issue) string { | |||||||
| func getProjects() []string { | func getProjects() []string { | ||||||
| 	// see if project is set to a single string | 	// see if project is set to a single string | ||||||
| 	configPath := "wtf.mods.jira.project" | 	configPath := "wtf.mods.jira.project" | ||||||
| 	singleProject, err := Config.String(configPath) | 	singleProject, err := wtf.Config.String(configPath) | ||||||
| 	if err == nil { | 	if err == nil { | ||||||
| 		return []string{singleProject} | 		return []string{singleProject} | ||||||
| 	} | 	} | ||||||
| 	// else, assume list | 	// else, assume list | ||||||
| 	projList := Config.UList(configPath) | 	projList := wtf.Config.UList(configPath) | ||||||
| 	var ret []string | 	var ret []string | ||||||
| 	for _, proj := range projList { | 	for _, proj := range projList { | ||||||
| 		if str, ok := proj.(string); ok { | 		if str, ok := proj.(string); ok { | ||||||
|  | |||||||
| @ -3,13 +3,14 @@ package newrelic | |||||||
| import ( | import ( | ||||||
| 	"os" | 	"os" | ||||||
| 
 | 
 | ||||||
|  | 	"github.com/senorprogrammer/wtf/wtf" | ||||||
| 	nr "github.com/yfronto/newrelic" | 	nr "github.com/yfronto/newrelic" | ||||||
| ) | ) | ||||||
| 
 | 
 | ||||||
| func Application() (*nr.Application, error) { | func Application() (*nr.Application, error) { | ||||||
| 	client := nr.NewClient(os.Getenv("WTF_NEW_RELIC_API_KEY")) | 	client := nr.NewClient(os.Getenv("WTF_NEW_RELIC_API_KEY")) | ||||||
| 
 | 
 | ||||||
| 	application, err := client.GetApplication(Config.UInt("wtf.mods.newrelic.applicationId")) | 	application, err := client.GetApplication(wtf.Config.UInt("wtf.mods.newrelic.applicationId")) | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		return nil, err | 		return nil, err | ||||||
| 	} | 	} | ||||||
| @ -21,7 +22,7 @@ func Deployments() ([]nr.ApplicationDeployment, error) { | |||||||
| 	client := nr.NewClient(os.Getenv("WTF_NEW_RELIC_API_KEY")) | 	client := nr.NewClient(os.Getenv("WTF_NEW_RELIC_API_KEY")) | ||||||
| 
 | 
 | ||||||
| 	opts := &nr.ApplicationDeploymentOptions{Page: 1} | 	opts := &nr.ApplicationDeploymentOptions{Page: 1} | ||||||
| 	deployments, err := client.GetApplicationDeployments(Config.UInt("wtf.mods.newrelic.applicationId"), opts) | 	deployments, err := client.GetApplicationDeployments(wtf.Config.UInt("wtf.mods.newrelic.applicationId"), opts) | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		return nil, err | 		return nil, err | ||||||
| 	} | 	} | ||||||
|  | |||||||
| @ -3,14 +3,10 @@ package newrelic | |||||||
| import ( | import ( | ||||||
| 	"fmt" | 	"fmt" | ||||||
| 
 | 
 | ||||||
| 	"github.com/olebedev/config" |  | ||||||
| 	"github.com/senorprogrammer/wtf/wtf" | 	"github.com/senorprogrammer/wtf/wtf" | ||||||
| 	nr "github.com/yfronto/newrelic" | 	nr "github.com/yfronto/newrelic" | ||||||
| ) | ) | ||||||
| 
 | 
 | ||||||
| // Config is a pointer to the global config object |  | ||||||
| var Config *config.Config |  | ||||||
| 
 |  | ||||||
| type Widget struct { | type Widget struct { | ||||||
| 	wtf.TextWidget | 	wtf.TextWidget | ||||||
| } | } | ||||||
| @ -79,7 +75,7 @@ func (widget *Widget) contentFrom(deploys []nr.ApplicationDeployment) string { | |||||||
| 
 | 
 | ||||||
| 			revisions = append(revisions, deploy.Revision) | 			revisions = append(revisions, deploy.Revision) | ||||||
| 
 | 
 | ||||||
| 			if len(revisions) == Config.UInt("wtf.mods.newrelic.deployCount", 5) { | 			if len(revisions) == wtf.Config.UInt("wtf.mods.newrelic.deployCount", 5) { | ||||||
| 				break | 				break | ||||||
| 			} | 			} | ||||||
| 		} | 		} | ||||||
|  | |||||||
| @ -4,13 +4,9 @@ import ( | |||||||
| 	"fmt" | 	"fmt" | ||||||
| 	"strings" | 	"strings" | ||||||
| 
 | 
 | ||||||
| 	"github.com/olebedev/config" |  | ||||||
| 	"github.com/senorprogrammer/wtf/wtf" | 	"github.com/senorprogrammer/wtf/wtf" | ||||||
| ) | ) | ||||||
| 
 | 
 | ||||||
| // Config is a pointer to the global config object |  | ||||||
| var Config *config.Config |  | ||||||
| 
 |  | ||||||
| type Widget struct { | type Widget struct { | ||||||
| 	wtf.TextWidget | 	wtf.TextWidget | ||||||
| } | } | ||||||
| @ -45,7 +41,7 @@ func (widget *Widget) Refresh() { | |||||||
| func (widget *Widget) contentFrom(onCallResponse *OnCallResponse) string { | func (widget *Widget) contentFrom(onCallResponse *OnCallResponse) string { | ||||||
| 	str := "" | 	str := "" | ||||||
| 
 | 
 | ||||||
| 	displayEmpty := Config.UBool("wtf.mods.opsgenie.displayEmpty", true) | 	displayEmpty := wtf.Config.UBool("wtf.mods.opsgenie.displayEmpty", true) | ||||||
| 
 | 
 | ||||||
| 	for _, data := range onCallResponse.OnCallData { | 	for _, data := range onCallResponse.OnCallData { | ||||||
| 		if (len(data.Recipients) == 0) && (displayEmpty == false) { | 		if (len(data.Recipients) == 0) && (displayEmpty == false) { | ||||||
|  | |||||||
| @ -3,13 +3,9 @@ package power | |||||||
| import ( | import ( | ||||||
| 	"fmt" | 	"fmt" | ||||||
| 
 | 
 | ||||||
| 	"github.com/olebedev/config" |  | ||||||
| 	"github.com/senorprogrammer/wtf/wtf" | 	"github.com/senorprogrammer/wtf/wtf" | ||||||
| ) | ) | ||||||
| 
 | 
 | ||||||
| // Config is a pointer to the global config object |  | ||||||
| var Config *config.Config |  | ||||||
| 
 |  | ||||||
| type Widget struct { | type Widget struct { | ||||||
| 	wtf.TextWidget | 	wtf.TextWidget | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -6,13 +6,9 @@ import ( | |||||||
| 	"fmt" | 	"fmt" | ||||||
| 	"strings" | 	"strings" | ||||||
| 
 | 
 | ||||||
| 	"github.com/olebedev/config" |  | ||||||
| 	"github.com/senorprogrammer/wtf/wtf" | 	"github.com/senorprogrammer/wtf/wtf" | ||||||
| ) | ) | ||||||
| 
 | 
 | ||||||
| // Config is a pointer to the global config object |  | ||||||
| var Config *config.Config |  | ||||||
| 
 |  | ||||||
| type Widget struct { | type Widget struct { | ||||||
| 	wtf.TextWidget | 	wtf.TextWidget | ||||||
| } | } | ||||||
|  | |||||||
| @ -6,13 +6,9 @@ import ( | |||||||
| 	"fmt" | 	"fmt" | ||||||
| 	"strings" | 	"strings" | ||||||
| 
 | 
 | ||||||
| 	"github.com/olebedev/config" |  | ||||||
| 	"github.com/senorprogrammer/wtf/wtf" | 	"github.com/senorprogrammer/wtf/wtf" | ||||||
| ) | ) | ||||||
| 
 | 
 | ||||||
| // Config is a pointer to the global config object |  | ||||||
| var Config *config.Config |  | ||||||
| 
 |  | ||||||
| type Widget struct { | type Widget struct { | ||||||
| 	wtf.TextWidget | 	wtf.TextWidget | ||||||
| } | } | ||||||
|  | |||||||
| @ -3,13 +3,9 @@ package status | |||||||
| import ( | import ( | ||||||
| 	"fmt" | 	"fmt" | ||||||
| 
 | 
 | ||||||
| 	"github.com/olebedev/config" |  | ||||||
| 	"github.com/senorprogrammer/wtf/wtf" | 	"github.com/senorprogrammer/wtf/wtf" | ||||||
| ) | ) | ||||||
| 
 | 
 | ||||||
| // Config is a pointer to the global config object |  | ||||||
| var Config *config.Config |  | ||||||
| 
 |  | ||||||
| type Widget struct { | type Widget struct { | ||||||
| 	wtf.TextWidget | 	wtf.TextWidget | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -4,13 +4,9 @@ import ( | |||||||
| 	"fmt" | 	"fmt" | ||||||
| 	"time" | 	"time" | ||||||
| 
 | 
 | ||||||
| 	"github.com/olebedev/config" |  | ||||||
| 	"github.com/senorprogrammer/wtf/wtf" | 	"github.com/senorprogrammer/wtf/wtf" | ||||||
| ) | ) | ||||||
| 
 | 
 | ||||||
| // Config is a pointer to the global config object |  | ||||||
| var Config *config.Config |  | ||||||
| 
 |  | ||||||
| type Widget struct { | type Widget struct { | ||||||
| 	wtf.TextWidget | 	wtf.TextWidget | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -5,14 +5,10 @@ import ( | |||||||
| 	"io/ioutil" | 	"io/ioutil" | ||||||
| 
 | 
 | ||||||
| 	"github.com/gdamore/tcell" | 	"github.com/gdamore/tcell" | ||||||
| 	"github.com/olebedev/config" |  | ||||||
| 	"github.com/rivo/tview" | 	"github.com/rivo/tview" | ||||||
| 	"github.com/senorprogrammer/wtf/wtf" | 	"github.com/senorprogrammer/wtf/wtf" | ||||||
| ) | ) | ||||||
| 
 | 
 | ||||||
| // Config is a pointer to the global config object |  | ||||||
| var Config *config.Config |  | ||||||
| 
 |  | ||||||
| const HelpText = ` | const HelpText = ` | ||||||
|   Keyboard commands for Textfile: |   Keyboard commands for Textfile: | ||||||
| 
 | 
 | ||||||
| @ -33,7 +29,7 @@ func NewWidget(app *tview.Application, pages *tview.Pages) *Widget { | |||||||
| 		TextWidget: wtf.NewTextWidget(" Text File ", "textfile", true), | 		TextWidget: wtf.NewTextWidget(" Text File ", "textfile", true), | ||||||
| 
 | 
 | ||||||
| 		app:      app, | 		app:      app, | ||||||
| 		filePath: Config.UString("wtf.mods.textfile.filePath"), | 		filePath: wtf.Config.UString("wtf.mods.textfile.filePath"), | ||||||
| 		pages:    pages, | 		pages:    pages, | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -33,15 +33,15 @@ func (widget *Widget) display() { | |||||||
| } | } | ||||||
| 
 | 
 | ||||||
| func (widget *Widget) formattedItemLine(item *Item, selectedItem *Item, maxLen int) string { | func (widget *Widget) formattedItemLine(item *Item, selectedItem *Item, maxLen int) string { | ||||||
| 	foreColor, backColor := "white", Config.UString("wtf.colors.background", "black") | 	foreColor, backColor := "white", wtf.Config.UString("wtf.colors.background", "black") | ||||||
| 
 | 
 | ||||||
| 	if item.Checked { | 	if item.Checked { | ||||||
| 		foreColor = Config.UString("wtf.mods.todo.colors.checked", "white") | 		foreColor = wtf.Config.UString("wtf.mods.todo.colors.checked", "white") | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	if widget.View.HasFocus() && (item == selectedItem) { | 	if widget.View.HasFocus() && (item == selectedItem) { | ||||||
| 		foreColor = Config.UString("wtf.mods.todo.colors.highlight.fore", "black") | 		foreColor = wtf.Config.UString("wtf.mods.todo.colors.highlight.fore", "black") | ||||||
| 		backColor = Config.UString("wtf.mods.todo.colors.highlight.back", "white") | 		backColor = wtf.Config.UString("wtf.mods.todo.colors.highlight.back", "white") | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	str := fmt.Sprintf( | 	str := fmt.Sprintf( | ||||||
|  | |||||||
| @ -1,5 +1,9 @@ | |||||||
| package todo | package todo | ||||||
| 
 | 
 | ||||||
|  | import ( | ||||||
|  | 	"github.com/senorprogrammer/wtf/wtf" | ||||||
|  | ) | ||||||
|  | 
 | ||||||
| type Item struct { | type Item struct { | ||||||
| 	Checked bool | 	Checked bool | ||||||
| 	Text    string | 	Text    string | ||||||
| @ -7,7 +11,7 @@ type Item struct { | |||||||
| 
 | 
 | ||||||
| func (item *Item) CheckMark() string { | func (item *Item) CheckMark() string { | ||||||
| 	if item.Checked { | 	if item.Checked { | ||||||
| 		return Config.UString("wtf.mods.todo.checkedIcon", "x") | 		return wtf.Config.UString("wtf.mods.todo.checkedIcon", "x") | ||||||
| 	} else { | 	} else { | ||||||
| 		return " " | 		return " " | ||||||
| 	} | 	} | ||||||
|  | |||||||
| @ -5,16 +5,12 @@ import ( | |||||||
| 	"io/ioutil" | 	"io/ioutil" | ||||||
| 
 | 
 | ||||||
| 	"github.com/gdamore/tcell" | 	"github.com/gdamore/tcell" | ||||||
| 	"github.com/olebedev/config" |  | ||||||
| 	"github.com/rivo/tview" | 	"github.com/rivo/tview" | ||||||
| 	"github.com/senorprogrammer/wtf/cfg" | 	"github.com/senorprogrammer/wtf/cfg" | ||||||
| 	"github.com/senorprogrammer/wtf/wtf" | 	"github.com/senorprogrammer/wtf/wtf" | ||||||
| 	"gopkg.in/yaml.v2" | 	"gopkg.in/yaml.v2" | ||||||
| ) | ) | ||||||
| 
 | 
 | ||||||
| // Config is a pointer to the global config object |  | ||||||
| var Config *config.Config |  | ||||||
| 
 |  | ||||||
| const HelpText = ` | const HelpText = ` | ||||||
|  Keyboard commands for Todo: |  Keyboard commands for Todo: | ||||||
| 
 | 
 | ||||||
| @ -52,7 +48,7 @@ func NewWidget(app *tview.Application, pages *tview.Pages) *Widget { | |||||||
| 		TextWidget: wtf.NewTextWidget(" Todo ", "todo", true), | 		TextWidget: wtf.NewTextWidget(" Todo ", "todo", true), | ||||||
| 
 | 
 | ||||||
| 		app:      app, | 		app:      app, | ||||||
| 		filePath: Config.UString("wtf.mods.todo.filename"), | 		filePath: wtf.Config.UString("wtf.mods.todo.filename"), | ||||||
| 		list:     &List{selected: -1}, | 		list:     &List{selected: -1}, | ||||||
| 		pages:    pages, | 		pages:    pages, | ||||||
| 	} | 	} | ||||||
|  | |||||||
| @ -6,13 +6,9 @@ import ( | |||||||
| 	"net/http" | 	"net/http" | ||||||
| 	"strings" | 	"strings" | ||||||
| 
 | 
 | ||||||
| 	"github.com/olebedev/config" |  | ||||||
| 	"github.com/senorprogrammer/wtf/wtf" | 	"github.com/senorprogrammer/wtf/wtf" | ||||||
| ) | ) | ||||||
| 
 | 
 | ||||||
| // Config is a pointer to the global config object |  | ||||||
| var Config *config.Config |  | ||||||
| 
 |  | ||||||
| type Widget struct { | type Widget struct { | ||||||
| 	wtf.TextWidget | 	wtf.TextWidget | ||||||
| 	result string | 	result string | ||||||
| @ -39,9 +35,9 @@ func (widget *Widget) Refresh() { | |||||||
| //this method reads the config and calls wttr.in for pretty weather | //this method reads the config and calls wttr.in for pretty weather | ||||||
| func (widget *Widget) prettyWeather() { | func (widget *Widget) prettyWeather() { | ||||||
| 	client := &http.Client{} | 	client := &http.Client{} | ||||||
| 	widget.unit = Config.UString("wtf.mods.prettyweather.unit", "m") | 	widget.unit = wtf.Config.UString("wtf.mods.prettyweather.unit", "m") | ||||||
| 	widget.city = Config.UString("wtf.mods.prettyweather.city", "") | 	widget.city = wtf.Config.UString("wtf.mods.prettyweather.city", "") | ||||||
| 	widget.view = Config.UString("wtf.mods.prettyweather.view", "0") | 	widget.view = wtf.Config.UString("wtf.mods.prettyweather.view", "0") | ||||||
| 	req, err := http.NewRequest("GET", "https://wttr.in/"+widget.city+"?"+widget.view+"?"+widget.unit, nil) | 	req, err := http.NewRequest("GET", "https://wttr.in/"+widget.city+"?"+widget.view+"?"+widget.unit, nil) | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		widget.result = fmt.Sprintf("%s", err.Error()) | 		widget.result = fmt.Sprintf("%s", err.Error()) | ||||||
|  | |||||||
| @ -55,14 +55,14 @@ func (widget *Widget) sunInfo(cityData *owm.CurrentWeatherData) string { | |||||||
| } | } | ||||||
| 
 | 
 | ||||||
| func (widget *Widget) temperatures(cityData *owm.CurrentWeatherData) string { | func (widget *Widget) temperatures(cityData *owm.CurrentWeatherData) string { | ||||||
| 	tempUnit := Config.UString("wtf.mods.weather.tempUnit", "C") | 	tempUnit := wtf.Config.UString("wtf.mods.weather.tempUnit", "C") | ||||||
| 
 | 
 | ||||||
| 	str := fmt.Sprintf("%8s: %4.1f° %s\n", "High", cityData.Main.TempMax, tempUnit) | 	str := fmt.Sprintf("%8s: %4.1f° %s\n", "High", cityData.Main.TempMax, tempUnit) | ||||||
| 
 | 
 | ||||||
| 	str = str + fmt.Sprintf( | 	str = str + fmt.Sprintf( | ||||||
| 		"%8s: [%s]%4.1f° %s[white]\n", | 		"%8s: [%s]%4.1f° %s[white]\n", | ||||||
| 		"Current", | 		"Current", | ||||||
| 		Config.UString("wtf.mods.weather.colors.current", "green"), | 		wtf.Config.UString("wtf.mods.weather.colors.current", "green"), | ||||||
| 		cityData.Main.Temp, | 		cityData.Main.Temp, | ||||||
| 		tempUnit, | 		tempUnit, | ||||||
| 	) | 	) | ||||||
|  | |||||||
| @ -5,14 +5,10 @@ import ( | |||||||
| 
 | 
 | ||||||
| 	owm "github.com/briandowns/openweathermap" | 	owm "github.com/briandowns/openweathermap" | ||||||
| 	"github.com/gdamore/tcell" | 	"github.com/gdamore/tcell" | ||||||
| 	"github.com/olebedev/config" |  | ||||||
| 	"github.com/rivo/tview" | 	"github.com/rivo/tview" | ||||||
| 	"github.com/senorprogrammer/wtf/wtf" | 	"github.com/senorprogrammer/wtf/wtf" | ||||||
| ) | ) | ||||||
| 
 | 
 | ||||||
| // Config is a pointer to the global config object. |  | ||||||
| var Config *config.Config |  | ||||||
| 
 |  | ||||||
| const HelpText = ` | const HelpText = ` | ||||||
|   Keyboard commands for Weather: |   Keyboard commands for Weather: | ||||||
| 
 | 
 | ||||||
| @ -75,7 +71,7 @@ func (widget *Widget) Fetch(cityIDs []int) []*owm.CurrentWeatherData { | |||||||
| // widget's view for rendering | // widget's view for rendering | ||||||
| func (widget *Widget) Refresh() { | func (widget *Widget) Refresh() { | ||||||
| 	if widget.apiKeyValid() { | 	if widget.apiKeyValid() { | ||||||
| 		widget.Data = widget.Fetch(wtf.ToInts(Config.UList("wtf.mods.weather.cityids", widget.defaultCityCodes()))) | 		widget.Data = widget.Fetch(wtf.ToInts(wtf.Config.UList("wtf.mods.weather.cityids", widget.defaultCityCodes()))) | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	widget.UpdateRefreshedAt() | 	widget.UpdateRefreshedAt() | ||||||
| @ -131,7 +127,11 @@ func (widget *Widget) currentData() *owm.CurrentWeatherData { | |||||||
| } | } | ||||||
| 
 | 
 | ||||||
| func (widget *Widget) currentWeather(apiKey string, cityCode int) (*owm.CurrentWeatherData, error) { | func (widget *Widget) currentWeather(apiKey string, cityCode int) (*owm.CurrentWeatherData, error) { | ||||||
| 	weather, err := owm.NewCurrent(Config.UString("wtf.mods.weather.tempUnit", "C"), Config.UString("wtf.mods.weather.language", "EN"), apiKey) | 	weather, err := owm.NewCurrent( | ||||||
|  | 		wtf.Config.UString("wtf.mods.weather.tempUnit", "C"), | ||||||
|  | 		wtf.Config.UString("wtf.mods.weather.language", "EN"), | ||||||
|  | 		apiKey, | ||||||
|  | 	) | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		return nil, err | 		return nil, err | ||||||
| 	} | 	} | ||||||
|  | |||||||
							
								
								
									
										29
									
								
								wtf.go
									
									
									
									
									
								
							
							
						
						
									
										29
									
								
								wtf.go
									
									
									
									
									
								
							| @ -88,35 +88,6 @@ func keyboardIntercept(event *tcell.EventKey) *tcell.EventKey { | |||||||
| 
 | 
 | ||||||
| func loadConfigFile(filePath string) { | func loadConfigFile(filePath string) { | ||||||
| 	Config = cfg.LoadConfigFile(filePath) | 	Config = cfg.LoadConfigFile(filePath) | ||||||
| 
 |  | ||||||
| 	// Always in alphabetical order |  | ||||||
| 	bamboohr.Config = Config |  | ||||||
| 	bargraph.Config = Config |  | ||||||
| 	bittrex.Config = Config |  | ||||||
| 	blockfolio.Config = Config |  | ||||||
| 	circleci.Config = Config |  | ||||||
| 	clocks.Config = Config |  | ||||||
| 	cmdrunner.Config = Config |  | ||||||
| 	cryptolive.Config = Config |  | ||||||
| 	gcal.Config = Config |  | ||||||
| 	git.Config = Config |  | ||||||
| 	github.Config = Config |  | ||||||
| 	gitlab.Config = Config |  | ||||||
| 	gspreadsheets.Config = Config |  | ||||||
| 	ipapi.Config = Config |  | ||||||
| 	ipinfo.Config = Config |  | ||||||
| 	jenkins.Config = Config |  | ||||||
| 	jira.Config = Config |  | ||||||
| 	newrelic.Config = Config |  | ||||||
| 	opsgenie.Config = Config |  | ||||||
| 	power.Config = Config |  | ||||||
| 	prettyweather.Config = Config |  | ||||||
| 	security.Config = Config |  | ||||||
| 	status.Config = Config |  | ||||||
| 	system.Config = Config |  | ||||||
| 	textfile.Config = Config |  | ||||||
| 	todo.Config = Config |  | ||||||
| 	weather.Config = Config |  | ||||||
| 	wtf.Config = Config | 	wtf.Config = Config | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user