mirror of
https://github.com/JanDeDobbeleer/oh-my-posh.git
synced 2024-12-28 04:19:41 -08:00
parent
230f8f4973
commit
74da88f99c
|
@ -36,6 +36,8 @@ const (
|
|||
CacheKeyResponse string = "owm_response"
|
||||
// CacheKeyURL key used when caching the url responsible for the response
|
||||
CacheKeyURL string = "owm_url"
|
||||
|
||||
PoshOWMAPIKey = "POSH_OWM_API_KEY"
|
||||
)
|
||||
|
||||
type weather struct {
|
||||
|
@ -90,6 +92,14 @@ func (d *Owm) getResult() (*owmDataResponse, error) {
|
|||
}
|
||||
|
||||
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")
|
||||
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
|
||||
|
|
|
@ -38,8 +38,8 @@ import Config from "@site/src/components/Config.js";
|
|||
## Properties
|
||||
|
||||
| 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. |
|
||||
| `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` |
|
||||
|
|
Loading…
Reference in a new issue