mirror of
https://github.com/Adembc/lazyssh.git
synced 2026-07-14 12:13:34 +02:00
configure lint and fix its problems
This commit is contained in:
+5
-7
@@ -7,10 +7,6 @@ issues:
|
|||||||
exclude-use-default: false
|
exclude-use-default: false
|
||||||
|
|
||||||
exclude-rules:
|
exclude-rules:
|
||||||
# disable some linters for api packages
|
|
||||||
- path: "api/*"
|
|
||||||
linters:
|
|
||||||
- lll
|
|
||||||
|
|
||||||
# disable some linters for internal packages
|
# disable some linters for internal packages
|
||||||
- path: "internal/*"
|
- path: "internal/*"
|
||||||
@@ -18,6 +14,7 @@ issues:
|
|||||||
- dupl
|
- dupl
|
||||||
- lll
|
- lll
|
||||||
|
|
||||||
|
|
||||||
# exclude some linters for the test directory and test files
|
# exclude some linters for the test directory and test files
|
||||||
- path: test/.*|.*_test\.go
|
- path: test/.*|.*_test\.go
|
||||||
linters:
|
linters:
|
||||||
@@ -40,10 +37,8 @@ linters:
|
|||||||
- exhaustive
|
- exhaustive
|
||||||
- ginkgolinter
|
- ginkgolinter
|
||||||
- goconst
|
- goconst
|
||||||
- gocritic
|
|
||||||
- gocyclo
|
- gocyclo
|
||||||
- gofmt
|
- gofmt
|
||||||
- goheader
|
|
||||||
- goimports
|
- goimports
|
||||||
- goprintffuncname
|
- goprintffuncname
|
||||||
- gosec
|
- gosec
|
||||||
@@ -55,7 +50,9 @@ linters:
|
|||||||
- nakedret
|
- nakedret
|
||||||
- nolintlint
|
- nolintlint
|
||||||
- prealloc
|
- prealloc
|
||||||
|
- gocritic
|
||||||
- revive
|
- revive
|
||||||
|
- goheader
|
||||||
- staticcheck
|
- staticcheck
|
||||||
- typecheck
|
- typecheck
|
||||||
- unconvert
|
- unconvert
|
||||||
@@ -77,13 +74,14 @@ linters-settings:
|
|||||||
- rangeValCopy
|
- rangeValCopy
|
||||||
- unnamedResult
|
- unnamedResult
|
||||||
- whyNoLint
|
- whyNoLint
|
||||||
|
- hugeParam
|
||||||
|
|
||||||
goimports:
|
goimports:
|
||||||
local-prefixes: github.com/kubeflow/notebooks/workspaces/backend
|
local-prefixes: github.com/kubeflow/notebooks/workspaces/backend
|
||||||
|
|
||||||
goheader:
|
goheader:
|
||||||
template: |-
|
template: |-
|
||||||
Copyright 2024.
|
Copyright 2025.
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
|
|||||||
+14
@@ -1,3 +1,17 @@
|
|||||||
|
// Copyright 2025.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|||||||
@@ -1,3 +1,17 @@
|
|||||||
|
// Copyright 2025.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
package memory
|
package memory
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|||||||
@@ -1,3 +1,17 @@
|
|||||||
|
// Copyright 2025.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
package ui
|
package ui
|
||||||
|
|
||||||
import "time"
|
import "time"
|
||||||
|
|||||||
@@ -1,10 +1,24 @@
|
|||||||
|
// Copyright 2025.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
package ui
|
package ui
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/Adembc/lazyssh/internal/core/domain"
|
"github.com/Adembc/lazyssh/internal/core/domain"
|
||||||
"github.com/gdamore/tcell/v2"
|
tcell "github.com/gdamore/tcell/v2" // Explicit alias
|
||||||
"github.com/rivo/tview"
|
"github.com/rivo/tview"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -183,7 +197,7 @@ func (t *tui) hideSearchBar() {
|
|||||||
func (t *tui) refreshServerList() {
|
func (t *tui) refreshServerList() {
|
||||||
query := ""
|
query := ""
|
||||||
if t.searchVisible {
|
if t.searchVisible {
|
||||||
query = t.searchBar.GetText()
|
query = t.searchBar.InputField.GetText()
|
||||||
}
|
}
|
||||||
filtered, _ := t.serverService.ListServers(query)
|
filtered, _ := t.serverService.ListServers(query)
|
||||||
t.serverList.UpdateServers(filtered)
|
t.serverList.UpdateServers(filtered)
|
||||||
|
|||||||
@@ -1,10 +1,24 @@
|
|||||||
|
// Copyright 2025.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
package ui
|
package ui
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/gdamore/tcell/v2"
|
tcell "github.com/gdamore/tcell/v2" // Explicit alias
|
||||||
"github.com/rivo/tview"
|
"github.com/rivo/tview"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -42,7 +56,7 @@ func (h *AppHeader) build() {
|
|||||||
|
|
||||||
separator := h.createSeparator()
|
separator := h.createSeparator()
|
||||||
|
|
||||||
h.SetDirection(tview.FlexRow).
|
h.Flex.SetDirection(tview.FlexRow).
|
||||||
AddItem(headerBar, 1, 0, false).
|
AddItem(headerBar, 1, 0, false).
|
||||||
AddItem(separator, 1, 0, false)
|
AddItem(separator, 1, 0, false)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,21 @@
|
|||||||
|
// Copyright 2025.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
package ui
|
package ui
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/gdamore/tcell/v2"
|
tcell "github.com/gdamore/tcell/v2" // Explicit alias
|
||||||
"github.com/rivo/tview"
|
"github.com/rivo/tview"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,21 @@
|
|||||||
|
// Copyright 2025.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
package ui
|
package ui
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/gdamore/tcell/v2"
|
tcell "github.com/gdamore/tcell/v2" // Explicit alias
|
||||||
"github.com/rivo/tview"
|
"github.com/rivo/tview"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -20,7 +34,7 @@ func NewSearchBar() *SearchBar {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *SearchBar) build() {
|
func (s *SearchBar) build() {
|
||||||
s.SetLabel(" 🔍 Search: ").
|
s.InputField.SetLabel(" 🔍 Search: ").
|
||||||
SetFieldBackgroundColor(tcell.Color233).
|
SetFieldBackgroundColor(tcell.Color233).
|
||||||
SetFieldTextColor(tcell.Color252).
|
SetFieldTextColor(tcell.Color252).
|
||||||
SetFieldWidth(30).
|
SetFieldWidth(30).
|
||||||
@@ -29,13 +43,13 @@ func (s *SearchBar) build() {
|
|||||||
SetBorderColor(tcell.Color238).
|
SetBorderColor(tcell.Color238).
|
||||||
SetTitleColor(tcell.Color250)
|
SetTitleColor(tcell.Color250)
|
||||||
|
|
||||||
s.SetChangedFunc(func(text string) {
|
s.InputField.SetChangedFunc(func(text string) {
|
||||||
if s.onSearch != nil {
|
if s.onSearch != nil {
|
||||||
s.onSearch(text)
|
s.onSearch(text)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
s.SetDoneFunc(func(key tcell.Key) {
|
s.InputField.SetDoneFunc(func(key tcell.Key) {
|
||||||
if key == tcell.KeyEsc || key == tcell.KeyEnter {
|
if key == tcell.KeyEsc || key == tcell.KeyEnter {
|
||||||
if s.onEscape != nil {
|
if s.onEscape != nil {
|
||||||
s.onEscape()
|
s.onEscape()
|
||||||
|
|||||||
@@ -1,10 +1,24 @@
|
|||||||
|
// Copyright 2025.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
package ui
|
package ui
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/Adembc/lazyssh/internal/core/domain"
|
"github.com/Adembc/lazyssh/internal/core/domain"
|
||||||
"github.com/gdamore/tcell/v2"
|
tcell "github.com/gdamore/tcell/v2" // Explicit alias
|
||||||
"github.com/rivo/tview"
|
"github.com/rivo/tview"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -21,7 +35,7 @@ func NewServerDetails() *ServerDetails {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (sd *ServerDetails) build() {
|
func (sd *ServerDetails) build() {
|
||||||
sd.SetDynamicColors(true).
|
sd.TextView.SetDynamicColors(true).
|
||||||
SetWrap(true).
|
SetWrap(true).
|
||||||
SetBorder(true).
|
SetBorder(true).
|
||||||
SetTitle("Details").
|
SetTitle("Details").
|
||||||
@@ -35,9 +49,9 @@ func (sd *ServerDetails) UpdateServer(server domain.Server) {
|
|||||||
server.Alias, server.Host, server.User, server.Port,
|
server.Alias, server.Host, server.User, server.Port,
|
||||||
server.Key, joinTags(server.Tags), statusIcon(server.Status),
|
server.Key, joinTags(server.Tags), statusIcon(server.Status),
|
||||||
server.LastSeen.Format("2006-01-02 15:04"))
|
server.LastSeen.Format("2006-01-02 15:04"))
|
||||||
sd.SetText(text)
|
sd.TextView.SetText(text)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (sd *ServerDetails) ShowEmpty() {
|
func (sd *ServerDetails) ShowEmpty() {
|
||||||
sd.SetText("No servers match the current filter.")
|
sd.TextView.SetText("No servers match the current filter.")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,17 @@
|
|||||||
|
// Copyright 2025.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
package ui
|
package ui
|
||||||
|
|
||||||
import (
|
import (
|
||||||
@@ -7,7 +21,7 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/Adembc/lazyssh/internal/core/domain"
|
"github.com/Adembc/lazyssh/internal/core/domain"
|
||||||
"github.com/gdamore/tcell/v2"
|
tcell "github.com/gdamore/tcell/v2" // Explicit alias
|
||||||
"github.com/rivo/tview"
|
"github.com/rivo/tview"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -42,7 +56,7 @@ func (sf *ServerForm) build() {
|
|||||||
title = "Edit Server"
|
title = "Edit Server"
|
||||||
}
|
}
|
||||||
|
|
||||||
sf.SetBorder(true).
|
sf.Form.SetBorder(true).
|
||||||
SetTitle(title).
|
SetTitle(title).
|
||||||
SetTitleAlign(tview.AlignLeft).
|
SetTitleAlign(tview.AlignLeft).
|
||||||
SetBorderColor(tcell.Color238).
|
SetBorderColor(tcell.Color238).
|
||||||
@@ -50,9 +64,9 @@ func (sf *ServerForm) build() {
|
|||||||
|
|
||||||
sf.addFormFields()
|
sf.addFormFields()
|
||||||
|
|
||||||
sf.AddButton("Save", sf.handleSave)
|
sf.Form.AddButton("Save", sf.handleSave)
|
||||||
sf.AddButton("Cancel", sf.handleCancel)
|
sf.Form.AddButton("Cancel", sf.handleCancel)
|
||||||
sf.SetCancelFunc(sf.handleCancel)
|
sf.Form.SetCancelFunc(sf.handleCancel)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (sf *ServerForm) addFormFields() {
|
func (sf *ServerForm) addFormFields() {
|
||||||
@@ -76,12 +90,12 @@ func (sf *ServerForm) addFormFields() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sf.AddInputField("Alias:", defaultValues.Alias, 20, nil, nil)
|
sf.Form.AddInputField("Alias:", defaultValues.Alias, 20, nil, nil)
|
||||||
sf.AddInputField("Host/IP:", defaultValues.Host, 20, nil, nil)
|
sf.Form.AddInputField("Host/IP:", defaultValues.Host, 20, nil, nil)
|
||||||
sf.AddInputField("User:", defaultValues.User, 20, nil, nil)
|
sf.Form.AddInputField("User:", defaultValues.User, 20, nil, nil)
|
||||||
sf.AddInputField("Port:", defaultValues.Port, 20, nil, nil)
|
sf.Form.AddInputField("Port:", defaultValues.Port, 20, nil, nil)
|
||||||
sf.AddInputField("Key:", defaultValues.Key, 40, nil, nil)
|
sf.Form.AddInputField("Key:", defaultValues.Key, 40, nil, nil)
|
||||||
sf.AddInputField("Tags (comma):", defaultValues.Tags, 30, nil, nil)
|
sf.Form.AddInputField("Tags (comma):", defaultValues.Tags, 30, nil, nil)
|
||||||
|
|
||||||
statusDD := tview.NewDropDown().SetLabel("Status: ")
|
statusDD := tview.NewDropDown().SetLabel("Status: ")
|
||||||
statusOptions := []string{"online", "warn", "offline"}
|
statusOptions := []string{"online", "warn", "offline"}
|
||||||
@@ -93,7 +107,7 @@ func (sf *ServerForm) addFormFields() {
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
sf.AddFormItem(statusDD)
|
sf.Form.AddFormItem(statusDD)
|
||||||
}
|
}
|
||||||
|
|
||||||
type ServerFormData struct {
|
type ServerFormData struct {
|
||||||
@@ -108,12 +122,12 @@ type ServerFormData struct {
|
|||||||
|
|
||||||
func (sf *ServerForm) getFormData() ServerFormData {
|
func (sf *ServerForm) getFormData() ServerFormData {
|
||||||
return ServerFormData{
|
return ServerFormData{
|
||||||
Alias: strings.TrimSpace(sf.GetFormItem(0).(*tview.InputField).GetText()),
|
Alias: strings.TrimSpace(sf.Form.GetFormItem(0).(*tview.InputField).GetText()),
|
||||||
Host: strings.TrimSpace(sf.GetFormItem(1).(*tview.InputField).GetText()),
|
Host: strings.TrimSpace(sf.Form.GetFormItem(1).(*tview.InputField).GetText()),
|
||||||
User: strings.TrimSpace(sf.GetFormItem(2).(*tview.InputField).GetText()),
|
User: strings.TrimSpace(sf.Form.GetFormItem(2).(*tview.InputField).GetText()),
|
||||||
Port: strings.TrimSpace(sf.GetFormItem(3).(*tview.InputField).GetText()),
|
Port: strings.TrimSpace(sf.Form.GetFormItem(3).(*tview.InputField).GetText()),
|
||||||
Key: strings.TrimSpace(sf.GetFormItem(4).(*tview.InputField).GetText()),
|
Key: strings.TrimSpace(sf.Form.GetFormItem(4).(*tview.InputField).GetText()),
|
||||||
Tags: strings.TrimSpace(sf.GetFormItem(5).(*tview.InputField).GetText()),
|
Tags: strings.TrimSpace(sf.Form.GetFormItem(5).(*tview.InputField).GetText()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -155,7 +169,7 @@ func (sf *ServerForm) dataToServer(data ServerFormData) domain.Server {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_, status := sf.GetFormItem(6).(*tview.DropDown).GetCurrentOption()
|
_, status := sf.Form.GetFormItem(6).(*tview.DropDown).GetCurrentOption()
|
||||||
return domain.Server{
|
return domain.Server{
|
||||||
Alias: data.Alias,
|
Alias: data.Alias,
|
||||||
Host: data.Host,
|
Host: data.Host,
|
||||||
|
|||||||
@@ -1,8 +1,22 @@
|
|||||||
|
// Copyright 2025.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
package ui
|
package ui
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/Adembc/lazyssh/internal/core/domain"
|
"github.com/Adembc/lazyssh/internal/core/domain"
|
||||||
"github.com/gdamore/tcell/v2"
|
tcell "github.com/gdamore/tcell/v2" // Explicit alias
|
||||||
"github.com/rivo/tview"
|
"github.com/rivo/tview"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -22,17 +36,17 @@ func NewServerList() *ServerList {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (sl *ServerList) build() {
|
func (sl *ServerList) build() {
|
||||||
sl.ShowSecondaryText(false)
|
sl.List.ShowSecondaryText(false)
|
||||||
sl.SetBorder(true).
|
sl.List.SetBorder(true).
|
||||||
SetTitle("Servers").
|
SetTitle("Servers").
|
||||||
SetBorderColor(tcell.Color238).
|
SetBorderColor(tcell.Color238).
|
||||||
SetTitleColor(tcell.Color250)
|
SetTitleColor(tcell.Color250)
|
||||||
sl.
|
sl.List.
|
||||||
SetSelectedBackgroundColor(tcell.Color24).
|
SetSelectedBackgroundColor(tcell.Color24).
|
||||||
SetSelectedTextColor(tcell.Color255).
|
SetSelectedTextColor(tcell.Color255).
|
||||||
SetHighlightFullLine(true)
|
SetHighlightFullLine(true)
|
||||||
|
|
||||||
sl.SetChangedFunc(func(index int, mainText string, secondaryText string, shortcut rune) {
|
sl.List.SetChangedFunc(func(index int, mainText string, secondaryText string, shortcut rune) {
|
||||||
if index >= 0 && index < len(sl.servers) && sl.onSelectionChange != nil {
|
if index >= 0 && index < len(sl.servers) && sl.onSelectionChange != nil {
|
||||||
sl.onSelectionChange(sl.servers[index])
|
sl.onSelectionChange(sl.servers[index])
|
||||||
}
|
}
|
||||||
@@ -41,20 +55,20 @@ func (sl *ServerList) build() {
|
|||||||
|
|
||||||
func (sl *ServerList) UpdateServers(servers []domain.Server) {
|
func (sl *ServerList) UpdateServers(servers []domain.Server) {
|
||||||
sl.servers = servers
|
sl.servers = servers
|
||||||
sl.Clear()
|
sl.List.Clear()
|
||||||
|
|
||||||
for i := range servers {
|
for i := range servers {
|
||||||
primary, secondary := formatServerLine(servers[i])
|
primary, secondary := formatServerLine(servers[i])
|
||||||
idx := i
|
idx := i
|
||||||
sl.AddItem(primary, secondary, 0, func() {
|
sl.List.AddItem(primary, secondary, 0, func() {
|
||||||
if sl.onSelection != nil {
|
if sl.onSelection != nil {
|
||||||
sl.onSelection(sl.servers[idx])
|
sl.onSelection(sl.servers[idx])
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
if sl.GetItemCount() > 0 {
|
if sl.List.GetItemCount() > 0 {
|
||||||
sl.SetCurrentItem(0)
|
sl.List.SetCurrentItem(0)
|
||||||
if sl.onSelectionChange != nil {
|
if sl.onSelectionChange != nil {
|
||||||
sl.onSelectionChange(sl.servers[0])
|
sl.onSelectionChange(sl.servers[0])
|
||||||
}
|
}
|
||||||
@@ -62,7 +76,7 @@ func (sl *ServerList) UpdateServers(servers []domain.Server) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (sl *ServerList) GetSelectedServer() (domain.Server, bool) {
|
func (sl *ServerList) GetSelectedServer() (domain.Server, bool) {
|
||||||
idx := sl.GetCurrentItem()
|
idx := sl.List.GetCurrentItem()
|
||||||
if idx >= 0 && idx < len(sl.servers) {
|
if idx >= 0 && idx < len(sl.servers) {
|
||||||
return sl.servers[idx], true
|
return sl.servers[idx], true
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,24 @@
|
|||||||
|
// Copyright 2025.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
package ui
|
package ui
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/gdamore/tcell/v2"
|
tcell "github.com/gdamore/tcell/v2" // Explicit alias
|
||||||
"github.com/rivo/tview"
|
"github.com/rivo/tview"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,21 @@
|
|||||||
|
// Copyright 2025.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
package ui
|
package ui
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/gdamore/tcell/v2"
|
tcell "github.com/gdamore/tcell/v2" // Explicit alias
|
||||||
"github.com/rivo/tview"
|
"github.com/rivo/tview"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +1,24 @@
|
|||||||
|
// Copyright 2025.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
package ui
|
package ui
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/Adembc/lazyssh/internal/core/ports"
|
"github.com/Adembc/lazyssh/internal/core/ports"
|
||||||
"github.com/gdamore/tcell/v2"
|
tcell "github.com/gdamore/tcell/v2" // Explicit alias
|
||||||
"github.com/rivo/tview"
|
"github.com/rivo/tview"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,17 @@
|
|||||||
|
// Copyright 2025.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
package ui
|
package ui
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|||||||
@@ -1,3 +1,17 @@
|
|||||||
|
// Copyright 2025.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
package domain
|
package domain
|
||||||
|
|
||||||
import "time"
|
import "time"
|
||||||
|
|||||||
@@ -1,3 +1,17 @@
|
|||||||
|
// Copyright 2025.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
package ports
|
package ports
|
||||||
|
|
||||||
import "github.com/Adembc/lazyssh/internal/core/domain"
|
import "github.com/Adembc/lazyssh/internal/core/domain"
|
||||||
|
|||||||
@@ -1,3 +1,17 @@
|
|||||||
|
// Copyright 2025.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
package ports
|
package ports
|
||||||
|
|
||||||
import "github.com/Adembc/lazyssh/internal/core/domain"
|
import "github.com/Adembc/lazyssh/internal/core/domain"
|
||||||
|
|||||||
@@ -1,3 +1,17 @@
|
|||||||
|
// Copyright 2025.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
package services
|
package services
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ $(LOCALBIN):
|
|||||||
mkdir -p $(LOCALBIN)
|
mkdir -p $(LOCALBIN)
|
||||||
|
|
||||||
# Tool versions
|
# Tool versions
|
||||||
GOLANGCI_LINT_VERSION ?= v1.61.0
|
GOLANGCI_LINT_VERSION ?= v1.64.2
|
||||||
GOFUMPT_VERSION ?= v0.7.0
|
GOFUMPT_VERSION ?= v0.7.0
|
||||||
STATICCHECK_VERSION ?= 2024.1.1
|
STATICCHECK_VERSION ?= 2024.1.1
|
||||||
|
|
||||||
@@ -95,7 +95,7 @@ vet: ## Run go vet against code
|
|||||||
go vet ./...
|
go vet ./...
|
||||||
|
|
||||||
.PHONY: lint
|
.PHONY: lint
|
||||||
lint: golangci-lint ## Run golangci-lint linter
|
lint: golangci-lint fmt ## Run golangci-lint linter
|
||||||
$(GOLANGCI_LINT) run
|
$(GOLANGCI_LINT) run
|
||||||
|
|
||||||
.PHONY: lint-fix
|
.PHONY: lint-fix
|
||||||
|
|||||||
Reference in New Issue
Block a user