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:
@@ -55,14 +55,14 @@ func (widget *Widget) sunInfo(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 = str + fmt.Sprintf(
|
||||
"%8s: [%s]%4.1f° %s[white]\n",
|
||||
"Current",
|
||||
Config.UString("wtf.mods.weather.colors.current", "green"),
|
||||
wtf.Config.UString("wtf.mods.weather.colors.current", "green"),
|
||||
cityData.Main.Temp,
|
||||
tempUnit,
|
||||
)
|
||||
|
||||
@@ -5,14 +5,10 @@ import (
|
||||
|
||||
owm "github.com/briandowns/openweathermap"
|
||||
"github.com/gdamore/tcell"
|
||||
"github.com/olebedev/config"
|
||||
"github.com/rivo/tview"
|
||||
"github.com/senorprogrammer/wtf/wtf"
|
||||
)
|
||||
|
||||
// Config is a pointer to the global config object.
|
||||
var Config *config.Config
|
||||
|
||||
const HelpText = `
|
||||
Keyboard commands for Weather:
|
||||
|
||||
@@ -75,7 +71,7 @@ func (widget *Widget) Fetch(cityIDs []int) []*owm.CurrentWeatherData {
|
||||
// widget's view for rendering
|
||||
func (widget *Widget) Refresh() {
|
||||
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()
|
||||
@@ -131,7 +127,11 @@ func (widget *Widget) currentData() *owm.CurrentWeatherData {
|
||||
}
|
||||
|
||||
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 {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user