Skip to content

Commit

Permalink
chore: fix lint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Broderick-Westrope committed Nov 14, 2024
1 parent 6ef91c4 commit 97a4b0f
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 9 deletions.
5 changes: 3 additions & 2 deletions cmd/tetrigo/subcommands.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@ package main

import (
"fmt"
"github.com/Broderick-Westrope/tetrigo/internal/tui/starter"

tea "github.com/charmbracelet/bubbletea"

"github.com/Broderick-Westrope/tetrigo/internal/config"
"github.com/Broderick-Westrope/tetrigo/internal/data"
"github.com/Broderick-Westrope/tetrigo/internal/tui"
tea "github.com/charmbracelet/bubbletea"
"github.com/Broderick-Westrope/tetrigo/internal/tui/starter"
)

type MenuCmd struct{}
Expand Down
2 changes: 1 addition & 1 deletion internal/tui/starter/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ package starter
import (
"database/sql"
"errors"
"github.com/Broderick-Westrope/tetrigo/internal/tui/views"
"reflect"

"github.com/Broderick-Westrope/tetrigo/internal/config"
"github.com/Broderick-Westrope/tetrigo/internal/tui"
"github.com/Broderick-Westrope/tetrigo/internal/tui/views"
"github.com/charmbracelet/bubbles/key"
tea "github.com/charmbracelet/bubbletea"
)
Expand Down
8 changes: 5 additions & 3 deletions internal/tui/utils.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
package tui

import (
"errors"
"github.com/charmbracelet/bubbles/key"
"github.com/charmbracelet/lipgloss"
"github.com/charmbracelet/x/ansi"
"github.com/mattn/go-runewidth"

"errors"
"regexp"
"strings"
"unicode"
Expand Down Expand Up @@ -43,7 +44,7 @@ func ConstructKeyBinding(keys []string, desc string) key.Binding {
return key.NewBinding(key.WithKeys(keys...), key.WithHelp(buildHelpKeys(keys), desc))
}

// Window overlay (CREDIT: https://gist.github.com/ras0q/9bf5d81544b22302393f61206892e2cd) ------------------------------------
// Window overlay (CREDIT: https://gist.github.com/ras0q/9bf5d81544b22302393f61206892e2cd)

// OverlayCenter writes the overlay string onto the background string such that the middle of the
// overlay string will be at the middle of the overlay will be at the middle of the background.
Expand Down Expand Up @@ -95,7 +96,8 @@ func Overlay(bg, overlay string, row, col int, ignoreMarginWhitespace bool) (str
}

// removeMarginWhitespace preserves the background where the overlay line has leading or trailing whitespace.
// This is done by detecting those empty cells in the overlay string and replacing them with the corresponding background cells.
// This is done by detecting those empty cells in the overlay string and
// replacing them with the corresponding background cells.
//
//nolint:gocognit
func removeMarginWhitespace(bgLine, overlayLine string, col int) string {
Expand Down
12 changes: 10 additions & 2 deletions internal/tui/views/menu.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ package views

import (
"fmt"
"github.com/Broderick-Westrope/tetrigo/internal/tui/components"

"github.com/Broderick-Westrope/tetrigo/internal/tui"
"github.com/Broderick-Westrope/tetrigo/internal/tui/components"

"github.com/charmbracelet/bubbles/help"
"github.com/charmbracelet/bubbles/key"
tea "github.com/charmbracelet/bubbletea"
Expand Down Expand Up @@ -149,6 +150,7 @@ func (m MenuModel) startGame() (tea.Cmd, error) {
if !ok {
return nil, errInvalidValue
}

case "Mode":
picker, ok := i.model.(*components.HPickerModel)
if !ok {
Expand All @@ -158,8 +160,14 @@ func (m MenuModel) startGame() (tea.Cmd, error) {
if !ok {
return nil, errInvalidValue
}

case "Name":
playerName = i.model.(components.TextInputModel).Child.Value()
input, ok := i.model.(components.TextInputModel)
if !ok {
return nil, errInvalidModel
}
playerName = input.Child.Value()

default:
return nil, fmt.Errorf("invalid item label: %q", i.label)
}
Expand Down
3 changes: 2 additions & 1 deletion internal/tui/views/single.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ package views

import (
"fmt"
"github.com/Broderick-Westrope/tetrigo/internal/tui/components"
"strconv"
"time"

"github.com/Broderick-Westrope/tetrigo/internal/tui/components"

"github.com/Broderick-Westrope/tetrigo/internal/config"
"github.com/Broderick-Westrope/tetrigo/internal/data"
"github.com/Broderick-Westrope/tetrigo/internal/tui"
Expand Down

0 comments on commit 97a4b0f

Please sign in to comment.