From 38cb3d6d1bf39fa3bdedb8bed9a49e8d2a492ccd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=83=9E=E3=83=AA=E3=82=A6=E3=82=B9?= Date: Sun, 15 Jan 2023 13:25:11 -0500 Subject: [PATCH] Added style flag, fixed args issue --- mercator.go | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/mercator.go b/mercator.go index 8ad289b..c42d3fa 100644 --- a/mercator.go +++ b/mercator.go @@ -1,7 +1,7 @@ package main import ( - "os" + "flag" "strconv" "strings" @@ -14,10 +14,18 @@ type model struct { } func main() { - args := os.Args[1:] + var style int + flag.IntVar(&style, "style", int(mapview.OpenStreetMaps), "map style to use (0 - 11)") + flag.Parse() + + args := flag.Args() m := NewModel() + if style >= 0 && style < 12 { + m.mv.SetStyle(mapview.Style(style)) + } + var isLatLng bool = false if len(args) == 2 { lat, err1 := strconv.ParseFloat(args[0], 64) @@ -27,7 +35,7 @@ func main() { m.mv.SetLatLng(lat, lng, 15) } } - if len(args) < 2 || len(args) > 2 && !isLatLng { + if !isLatLng { m.mv.SetLocation(strings.Join(args, " "), 15) }