Skip to content

Commit

Permalink
feat(app): replace the the gui dependency with tui in the app
Browse files Browse the repository at this point in the history
  • Loading branch information
danvergara committed Oct 30, 2024
1 parent 1614eeb commit 412b810
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
15 changes: 7 additions & 8 deletions pkg/app/app.go
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
package app

import (
"github.com/danvergara/gocui"

"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
}

Expand All @@ -20,13 +21,13 @@ func New(g *gocui.Gui, opts command.Options) (*App, error) {
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 +36,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
4 changes: 2 additions & 2 deletions pkg/gui/gui.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ package gui
import (
"errors"

"github.com/danvergara/dblab/pkg/client"
"github.com/danvergara/gocui"

"github.com/danvergara/dblab/pkg/client"
)

// Gui wraps the gocui Gui object which handles rendering and events.
Expand All @@ -15,7 +16,6 @@ type Gui struct {

// New builds a new gui handler.
func New(g *gocui.Gui, c *client.Client) (*Gui, error) {

gui := Gui{
g: g,
c: c,
Expand Down

0 comments on commit 412b810

Please sign in to comment.