diff --git a/cmd/zmk-viewer/main.go b/cmd/zmk-viewer/main.go index 3c431f2..1e55400 100644 --- a/cmd/zmk-viewer/main.go +++ b/cmd/zmk-viewer/main.go @@ -29,8 +29,8 @@ func (d debugFlag) BeforeApply() error { return nil } -func (v VersionFlag) Decode(ctx *kong.DecodeContext) error { return nil } -func (v VersionFlag) IsBool() bool { return true } +func (v VersionFlag) Decode(_ *kong.DecodeContext) error { return nil } +func (v VersionFlag) IsBool() bool { return true } func (v VersionFlag) BeforeApply(app *kong.Kong) error { fmt.Printf("zmk-viewer has version %s built from %s on %s\n", version, commit, date) app.Exit(0) diff --git a/internal/lib/generate.go b/internal/lib/generate.go index 445d573..46a8f5d 100644 --- a/internal/lib/generate.go +++ b/internal/lib/generate.go @@ -108,9 +108,9 @@ func drawBehavior(ctx *gg.Context, key *keymap.Behavior, x float64, y float64) { for i, v := range key.Params { str := "" if v.KeyCode == nil { - str = str + fmt.Sprintf("%v", *v.Number) + str += fmt.Sprintf("%v", *v.Number) } else { - str = str + *v.KeyCode + str += *v.KeyCode } dw, dh := ctx.MeasureString(str) diff --git a/internal/lib/root.go b/internal/lib/root.go index ad11580..0247025 100644 --- a/internal/lib/root.go +++ b/internal/lib/root.go @@ -15,7 +15,7 @@ type GenerateCmd struct { KeyboardName string `arg:"" help:"Keyboard name to fetch layout."` File string `optional:"" short:"f" type:"existingfile" help:"ZMK .keymap file"` - LayoutFile string `optional:"" short:"l" type:"layoutfile" help:"info.json file"` + LayoutFile string `optional:"" short:"l" type:"existingfile" help:"info.json file"` Transparent bool `optional:"" short:"t" help:"Use a transparent background."` Output string `optional:"" short:"o" type:"existingdir" default:"." help:"Output directory."` } @@ -38,6 +38,7 @@ func (g *GenerateCmd) Run() error { g.KeyboardName = strings.ReplaceAll(g.KeyboardName, "/", "_") for layoutName, layout := range keyboardInfo { + layout := layout ctx := createContext(&layout) err := drawLayout(ctx, g.Transparent, layout) if err != nil { diff --git a/pkg/keyboard/keyboard.go b/pkg/keyboard/keyboard.go index 6eb6a7e..7ed2ef8 100644 --- a/pkg/keyboard/keyboard.go +++ b/pkg/keyboard/keyboard.go @@ -3,7 +3,7 @@ package keyboard import ( "encoding/json" "fmt" - "io/ioutil" + "io" "net/http" "os" "time" @@ -43,7 +43,7 @@ func fetch(url string) (*file, error) { Timeout: time.Second * 5, // Timeout after 2 seconds } - req, err := http.NewRequest(http.MethodGet, url, nil) + req, err := http.NewRequest(http.MethodGet, url, http.NoBody) if err != nil { return nil, err } @@ -59,7 +59,7 @@ func fetch(url string) (*file, error) { defer res.Body.Close() } - body, readErr := ioutil.ReadAll(res.Body) + body, readErr := io.ReadAll(res.Body) if readErr != nil { return nil, readErr } @@ -108,5 +108,4 @@ func LoadFile(name, path string) (Layouts, error) { } l := f.Layouts return l, nil - }