Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tview #240

Merged
merged 12 commits into from
Nov 4, 2024
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ Key | Description
<kbd>Ctrl+Space</kbd> | If the query panel is active, execute the query
<kbd>Enter</kbd> | If the tables panel is active, list all the rows as a result set on the rows panel and display the structure of the table on the structure panel
<kbd>Ctrl+S</kbd> | If the rows panel is active, switch to the schema panel. The opposite is true
<kbd>Ctrl+F</kbd> | If the rows panel is active, switch to the constraints view. The opposite is true
<kbd>Ctrl+T</kbd> | If the rows panel is active, switch to the constraints view. The opposite is true
<kbd>Ctrl+I</kbd> | If the rows panel is active, switch to the indexes view. The opposite is true
<kbd>Ctrl+H</kbd> | Toggle to the panel on the left
<kbd>Ctrl+J</kbd> | Toggle to the panel below
Expand Down
8 changes: 1 addition & 7 deletions cmd/root.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package cmd

import (
"github.com/danvergara/gocui"
"github.com/spf13/cobra"

"github.com/danvergara/dblab/pkg/app"
Expand Down Expand Up @@ -92,12 +91,7 @@ func NewRootCmd() *cobra.Command {
return err
}

gcui, err := gocui.NewGui(gocui.OutputNormal)
if err != nil {
return err
}

app, err := app.New(gcui, opts)
app, err := app.New(opts)
if err != nil {
return err
}
Expand Down
20 changes: 9 additions & 11 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ require (
github.com/charmbracelet/bubbletea v0.21.0
github.com/charmbracelet/lipgloss v0.5.0
github.com/common-nighthawk/go-figure v0.0.0-20210622060536-734e95fb86be
github.com/danvergara/gocui v0.6.0
github.com/fatih/color v1.13.0
github.com/gdamore/tcell/v2 v2.7.1
github.com/go-sql-driver/mysql v1.6.0
github.com/golang-migrate/migrate/v4 v4.15.2
github.com/google/go-cmp v0.5.9
Expand All @@ -19,11 +18,10 @@ require (
github.com/lib/pq v1.10.6
github.com/microsoft/go-mssqldb v1.7.2
github.com/muesli/termenv v0.12.0
github.com/olekukonko/tablewriter v0.0.5
github.com/rivo/tview v0.0.0-20241016194538-c5e4fb24af13
github.com/sijms/go-ora/v2 v2.8.19
github.com/spf13/cobra v1.4.0
github.com/stretchr/testify v1.8.4
golang.org/x/text v0.14.0
modernc.org/sqlite v1.22.1
)

Expand All @@ -38,6 +36,7 @@ require (
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/denisenkom/go-mssqldb v0.10.0 // indirect
github.com/dustin/go-humanize v1.0.1 // indirect
github.com/gdamore/encoding v1.0.0 // indirect
github.com/golang-jwt/jwt/v4 v4.1.0 // indirect
github.com/golang-sql/civil v0.0.0-20220223132316-b832511892a9 // indirect
github.com/golang-sql/sqlexp v0.1.0 // indirect
Expand All @@ -49,25 +48,24 @@ require (
github.com/lann/builder v0.0.0-20180802200727-47ae307949d0 // indirect
github.com/lann/ps v0.0.0-20150810152359-62de8c46ede0 // indirect
github.com/lucasb-eyer/go-colorful v1.2.0 // indirect
github.com/mattn/go-colorable v0.1.12 // indirect
github.com/mattn/go-isatty v0.0.16 // indirect
github.com/mattn/go-runewidth v0.0.13 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mattn/go-runewidth v0.0.15 // indirect
github.com/mattn/go-sqlite3 v1.14.16 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/muesli/ansi v0.0.0-20211031195517-c9f0611b6c70 // indirect
github.com/muesli/cancelreader v0.2.0 // indirect
github.com/muesli/reflow v0.3.0 // indirect
github.com/nsf/termbox-go v1.1.1 // indirect
github.com/pelletier/go-toml v1.9.5 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect
github.com/rivo/uniseg v0.2.0 // indirect
github.com/rivo/uniseg v0.4.7 // indirect
github.com/spf13/pflag v1.0.5 // indirect
go.uber.org/atomic v1.9.0 // indirect
golang.org/x/crypto v0.18.0 // indirect
golang.org/x/mod v0.8.0 // indirect
golang.org/x/sys v0.16.0 // indirect
golang.org/x/term v0.16.0 // indirect
golang.org/x/sys v0.25.0 // indirect
golang.org/x/term v0.17.0 // indirect
golang.org/x/text v0.14.0 // indirect
golang.org/x/tools v0.6.0 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
Expand Down
52 changes: 30 additions & 22 deletions go.sum

Large diffs are not rendered by default.

15 changes: 6 additions & 9 deletions pkg/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,29 @@ package app
import (
"github.com/danvergara/dblab/pkg/client"
"github.com/danvergara/dblab/pkg/command"
"github.com/danvergara/dblab/pkg/gui"
"github.com/danvergara/gocui"
"github.com/danvergara/dblab/pkg/tui"
)

// App Struct.
type App struct {
g *gui.Gui
t *tui.Tui
c *client.Client
}

// New bootstrap a new application.
func New(g *gocui.Gui, opts command.Options) (*App, error) {
func New(opts command.Options) (*App, error) {
c, err := client.New(opts)
if err != nil {
return nil, err
}

gcui, err := gui.New(g, c)
t, err := tui.New(c)
if err != nil {
return nil, err
}

app := App{
g: gcui,
t: t,
c: c,
}

Expand All @@ -35,13 +34,11 @@ func New(g *gocui.Gui, opts command.Options) (*App, error) {

// Run runs the application.
func (a *App) Run() error {

defer func() {
_ = a.c.DB().Close()
a.g.Gui().Close()
}()

if err := a.g.Run(); err != nil {
if err := a.t.Run(); err != nil {
return err
}

Expand Down
236 changes: 0 additions & 236 deletions pkg/gui/database_helpers.go

This file was deleted.

Loading