mirror of
https://github.com/taigrr/teaqlite.git
synced 2026-04-02 04:59:03 -07:00
modernize, fixup docstring
This commit is contained in:
@@ -1,2 +1,2 @@
|
|||||||
// package cmd provides the Cobra command-line interface for the TeaQLite application.
|
// Package cmd provides the Cobra command-line interface for the TeaQLite application.
|
||||||
package cmd
|
package cmd
|
||||||
|
|||||||
@@ -7,8 +7,8 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
|
|
||||||
tea "github.com/charmbracelet/bubbletea"
|
|
||||||
"github.com/charmbracelet/bubbles/key"
|
"github.com/charmbracelet/bubbles/key"
|
||||||
|
tea "github.com/charmbracelet/bubbletea"
|
||||||
"github.com/charmbracelet/lipgloss"
|
"github.com/charmbracelet/lipgloss"
|
||||||
_ "modernc.org/sqlite" // Import SQLite driver
|
_ "modernc.org/sqlite" // Import SQLite driver
|
||||||
)
|
)
|
||||||
@@ -26,7 +26,7 @@ func nextID() int {
|
|||||||
// Common message types
|
// Common message types
|
||||||
type blinkMsg struct{}
|
type blinkMsg struct{}
|
||||||
|
|
||||||
// KeyMap defines the keybindings for the application
|
// AppKeyMap defines the keybindings for the application
|
||||||
type AppKeyMap struct {
|
type AppKeyMap struct {
|
||||||
Quit key.Binding
|
Quit key.Binding
|
||||||
Suspend key.Binding
|
Suspend key.Binding
|
||||||
@@ -468,6 +468,7 @@ var (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// Utility functions
|
// Utility functions
|
||||||
|
|
||||||
func TruncateString(s string, maxLen int) string {
|
func TruncateString(s string, maxLen int) string {
|
||||||
if len(s) <= maxLen {
|
if len(s) <= maxLen {
|
||||||
return s
|
return s
|
||||||
|
|||||||
@@ -5,10 +5,10 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
tea "github.com/charmbracelet/bubbletea"
|
|
||||||
"github.com/charmbracelet/bubbles/help"
|
"github.com/charmbracelet/bubbles/help"
|
||||||
"github.com/charmbracelet/bubbles/key"
|
"github.com/charmbracelet/bubbles/key"
|
||||||
"github.com/charmbracelet/bubbles/textarea"
|
"github.com/charmbracelet/bubbles/textarea"
|
||||||
|
tea "github.com/charmbracelet/bubbletea"
|
||||||
)
|
)
|
||||||
|
|
||||||
type QueryModel struct {
|
type QueryModel struct {
|
||||||
@@ -110,7 +110,7 @@ func (m *QueryModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
|||||||
cmds = append(cmds, tea.Tick(time.Millisecond*500, func(t time.Time) tea.Msg {
|
cmds = append(cmds, tea.Tick(time.Millisecond*500, func(t time.Time) tea.Msg {
|
||||||
return blinkMsg{}
|
return blinkMsg{}
|
||||||
}))
|
}))
|
||||||
|
|
||||||
case tea.KeyMsg:
|
case tea.KeyMsg:
|
||||||
if m.FocusOnInput {
|
if m.FocusOnInput {
|
||||||
return m.handleQueryInput(msg)
|
return m.handleQueryInput(msg)
|
||||||
@@ -252,9 +252,7 @@ func (m *QueryModel) ensureIDColumns(query string) string {
|
|||||||
|
|
||||||
// Add primary keys to the beginning
|
// Add primary keys to the beginning
|
||||||
var pkList []string
|
var pkList []string
|
||||||
for _, pk := range primaryKeys {
|
pkList = append(pkList, primaryKeys...)
|
||||||
pkList = append(pkList, pk)
|
|
||||||
}
|
|
||||||
|
|
||||||
newSelectClause := strings.Join(pkList, ", ") + ", " + selectClause
|
newSelectClause := strings.Join(pkList, ", ") + ", " + selectClause
|
||||||
|
|
||||||
@@ -457,4 +455,5 @@ func (m *QueryModel) View() string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return content.String()
|
return content.String()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user