mirror of
https://github.com/JanDeDobbeleer/oh-my-posh.git
synced 2025-01-28 11:31:04 -08:00
parent
230f8f4973
commit
74da88f99c
|
@ -36,6 +36,8 @@ const (
|
||||||
CacheKeyResponse string = "owm_response"
|
CacheKeyResponse string = "owm_response"
|
||||||
// CacheKeyURL key used when caching the url responsible for the response
|
// CacheKeyURL key used when caching the url responsible for the response
|
||||||
CacheKeyURL string = "owm_url"
|
CacheKeyURL string = "owm_url"
|
||||||
|
|
||||||
|
PoshOWMAPIKey = "POSH_OWM_API_KEY"
|
||||||
)
|
)
|
||||||
|
|
||||||
type weather struct {
|
type weather struct {
|
||||||
|
@ -90,6 +92,14 @@ func (d *Owm) getResult() (*owmDataResponse, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
apikey := properties.OneOf[string](d.props, ".", APIKey, "apiKey")
|
apikey := properties.OneOf[string](d.props, ".", APIKey, "apiKey")
|
||||||
|
if len(apikey) == 0 {
|
||||||
|
apikey = d.env.Getenv(PoshOWMAPIKey)
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(apikey) == 0 {
|
||||||
|
return nil, errors.New("no api key found")
|
||||||
|
}
|
||||||
|
|
||||||
location := d.props.GetString(Location, "De Bilt,NL")
|
location := d.props.GetString(Location, "De Bilt,NL")
|
||||||
latitude := d.props.GetFloat64(Latitude, 91) // This default value is intentionally invalid since there should not be a default for this and 0 is a valid value
|
latitude := d.props.GetFloat64(Latitude, 91) // This default value is intentionally invalid since there should not be a default for this and 0 is a valid value
|
||||||
longitude := d.props.GetFloat64(Longitude, 181) // This default value is intentionally invalid since there should not be a default for this and 0 is a valid value
|
longitude := d.props.GetFloat64(Longitude, 181) // This default value is intentionally invalid since there should not be a default for this and 0 is a valid value
|
||||||
|
|
|
@ -37,16 +37,16 @@ import Config from "@site/src/components/Config.js";
|
||||||
|
|
||||||
## Properties
|
## Properties
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| --------------- | --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
| --------------- | --------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||||
| `api_key` | `string` | Your API key from [Open Weather Map][owm] |
|
| `api_key` | `string` | Your API key from [Open Weather Map][owm]. Can also be set using the `POSH_OWM_API_KEY` environment variable. |
|
||||||
| `latitude` | `float64` | The latitude of the requested location. |
|
| `latitude` | `float64` | The latitude of the requested location. |
|
||||||
| `longitude` | `float64` | The longitude of the requested location. |
|
| `longitude` | `float64` | The longitude of the requested location. |
|
||||||
| `location` | `string` | The requested location. Formatted as \<City,STATE,COUNTRY_CODE\>. City name, state code and country code divided by comma. Please, refer to ISO 3166 for the state codes or country codes - defaults to `DE BILT,NL` |
|
| `location` | `string` | The requested location. Formatted as \<City,STATE,COUNTRY_CODE\>. City name, state code and country code divided by comma. Please, refer to ISO 3166 for the state codes or country codes - defaults to `DE BILT,NL` |
|
||||||
| `units` | `string` | Units of measurement. Available values are standard (kelvin), metric (celsius), and imperial (fahrenheit) - defaults to `standard` |
|
| `units` | `string` | Units of measurement. Available values are standard (kelvin), metric (celsius), and imperial (fahrenheit) - defaults to `standard` |
|
||||||
| `http_timeout` | `int` | The default timeout for http request is 20ms. |
|
| `http_timeout` | `int` | The default timeout for http request is 20ms. |
|
||||||
| `cache_timeout` | `int` | The default timeout for request caching is 10m. A value of 0 disables the cache. |
|
| `cache_timeout` | `int` | The default timeout for request caching is 10m. A value of 0 disables the cache. |
|
||||||
| `template` | `string` | A go [text/template][go-text-template] template extended with [sprig][sprig] utilizing the properties below - defaults to `{{.Weather}} ({{.Temperature}}{{.UnitIcon}})` |
|
| `template` | `string` | A go [text/template][go-text-template] template extended with [sprig][sprig] utilizing the properties below - defaults to `{{.Weather}} ({{.Temperature}}{{.UnitIcon}})` |
|
||||||
|
|
||||||
### Specifying Location
|
### Specifying Location
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue