Skip to content

Commit

Permalink
Fix lint issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Vedu1996 committed Jan 11, 2024
1 parent ff96ba2 commit 201b998
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 32 deletions.
15 changes: 7 additions & 8 deletions internal/app/keymap.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,15 @@ package app
import "github.com/charmbracelet/bubbles/key"

type KeyMap struct {
Exit key.Binding
Back key.Binding
ToggleView key.Binding
Exit key.Binding
Back key.Binding
ToggleView key.Binding
ToggleViewArrow key.Binding
Up key.Binding
Down key.Binding
Filter key.Binding
Up key.Binding
Down key.Binding
Filter key.Binding
}


var defaultKeys = KeyMap{
Exit: key.NewBinding(
key.WithKeys("ctrl+c", "f10"),
Expand Down Expand Up @@ -52,4 +51,4 @@ func (k KeyMap) FullHelp() [][]key.Binding {
{k.Back, k.Up, k.Down}, // first column
{k.ToggleView, k.Exit, k.Filter}, // second column
}
}
}
16 changes: 8 additions & 8 deletions internal/app/statefiltered.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ type StateFiltered struct {
logEntries source.LogEntries

filterText string
keys KeyMap
keys KeyMap
}

func newStateFiltered(
Expand All @@ -32,7 +32,7 @@ func newStateFiltered(
table: previousState.table,

filterText: filterText,
keys: defaultKeys,
keys: defaultKeys,
}
}

Expand Down Expand Up @@ -67,12 +67,12 @@ func (s StateFiltered) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
return s.handleOpenJSONRowRequestedMsg(msg, s)
case tea.KeyMsg:
switch {
case key.Matches(msg, s.keys.Back):
return s.previousState.withApplication(s.Application)
case key.Matches(msg, s.keys.Filter):
return s.handleFilterKeyClickedMsg()
case key.Matches(msg, s.keys.ToggleViewArrow) , key.Matches(msg, s.keys.ToggleView):
return s.handleRequestOpenJSON()
case key.Matches(msg, s.keys.Back):
return s.previousState.withApplication(s.Application)
case key.Matches(msg, s.keys.Filter):
return s.handleFilterKeyClickedMsg()
case key.Matches(msg, s.keys.ToggleViewArrow), key.Matches(msg, s.keys.ToggleView):
return s.handleRequestOpenJSON()
}
if cmd := s.handleKeyMsg(msg); cmd != nil {
return s, cmd
Expand Down
12 changes: 6 additions & 6 deletions internal/app/statefiltering.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ type StateFiltering struct {
table logsTableModel

textInput textinput.Model
keys KeyMap
keys KeyMap
}

func newStateFiltering(
Expand All @@ -33,7 +33,7 @@ func newStateFiltering(
table: previousState.table,

textInput: textInput,
keys: defaultKeys,
keys: defaultKeys,
}
}

Expand All @@ -58,10 +58,10 @@ func (s StateFiltering) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
return s.handleErrorOccuredMsg(msg)
case tea.KeyMsg:
switch {
case key.Matches(msg, s.keys.Back):
return s.previousState.withApplication(s.Application)
case key.Matches(msg, s.keys.ToggleView):
return s.handleEnterKeyClickedMsg()
case key.Matches(msg, s.keys.Back):
return s.previousState.withApplication(s.Application)
case key.Matches(msg, s.keys.ToggleView):
return s.handleEnterKeyClickedMsg()
}
if cmd := s.handleKeyMsg(msg); cmd != nil {
// Intercept table update.
Expand Down
13 changes: 6 additions & 7 deletions internal/app/stateloaded.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,15 +75,14 @@ func (s StateLoaded) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
return s.handleOpenJSONRowRequestedMsg(msg, s)
case tea.KeyMsg:
switch {
case key.Matches(msg, s.keys.Back):
return s, tea.Quit
case key.Matches(msg, s.keys.Filter):
return s.handleFilterKeyClickedMsg()
case key.Matches(msg, s.keys.ToggleViewArrow), key.Matches(msg, s.keys.ToggleView):
return s.handleRequestOpenJSON()
case key.Matches(msg, s.keys.Back):
return s, tea.Quit
case key.Matches(msg, s.keys.Filter):
return s.handleFilterKeyClickedMsg()
case key.Matches(msg, s.keys.ToggleViewArrow), key.Matches(msg, s.keys.ToggleView):
return s.handleRequestOpenJSON()
}
cmdBatch = append(cmdBatch, s.handleKeyMsg(msg)...)

}

s.table, cmdBatch = batched(s.table.Update(msg))(cmdBatch)
Expand Down
4 changes: 2 additions & 2 deletions internal/app/stateviewrow.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ func (s StateViewRow) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
return s.handleErrorOccuredMsg(msg)
case tea.KeyMsg:
switch {
case key.Matches(msg, s.keys.Back), key.Matches(msg, s.keys.ToggleView):
return s.previousState.withApplication(s.Application)
case key.Matches(msg, s.keys.Back), key.Matches(msg, s.keys.ToggleView):
return s.previousState.withApplication(s.Application)
}
if cmd = s.handleKeyMsg(msg); cmd != nil {
return s, cmd
Expand Down
1 change: 0 additions & 1 deletion internal/pkg/events/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ type (

// ViewRowsReloadRequestedMsg is an event to start reloading of logs.
ViewRowsReloadRequestedMsg struct{}

)

// OpenJSONRowRequested implements tea.Cmd. It creates OpenJSONRowRequestedMsg.
Expand Down

0 comments on commit 201b998

Please sign in to comment.