Add new option: --geo-resolve for geo queries

chubin/logging
Igor Chubin 2 years ago
parent caecca05cf
commit 1510ce6a88

@ -13,6 +13,7 @@ import (
"github.com/chubin/wttr.in/internal/config"
geoip "github.com/chubin/wttr.in/internal/geo/ip"
geoloc "github.com/chubin/wttr.in/internal/geo/location"
"github.com/chubin/wttr.in/internal/logging"
"github.com/chubin/wttr.in/internal/processor"
)
@ -20,6 +21,8 @@ import (
var cli struct {
ConfigCheck bool `name:"config-check" help:"Check configuration"`
ConfigDump bool `name:"config-dump" help:"Dump configuration"`
GeoResolve string `name:"geo-resolve" help:"Resolve location"`
ConfigFile string `name:"config-file" arg:"" optional:"" help:"Name of configuration file"`
ConvertGeoIPCache bool `name:"convert-geo-ip-cache" help:"Convert Geo IP data cache to SQlite"`
@ -185,6 +188,16 @@ func main() {
return
}
if cli.GeoResolve != "" {
sr := geoloc.NewSearcher(conf)
loc, err := sr.Search(cli.GeoResolve)
ctx.FatalIfErrorf(err)
if loc != nil {
fmt.Println(*loc)
}
}
err = serve(conf)
ctx.FatalIfErrorf(err)
}

Loading…
Cancel
Save