Skip to content

Commit

Permalink
Cleaned up model.
Browse files Browse the repository at this point in the history
  • Loading branch information
janderland committed Nov 25, 2023
1 parent 26a4a32 commit af79e85
Showing 1 changed file with 43 additions and 39 deletions.
82 changes: 43 additions & 39 deletions internal/app/fullscreen/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,33 +16,6 @@ import (
"github.com/janderland/fdbq/parser/format"
)

type Mode int

const (
modeScroll Mode = iota
modeInput
modeHelp
modeQuit
)

type Style struct {
results lip.Style
input lip.Style
}

type Model struct {
qm manager.QueryManager
log zerolog.Logger
latest time.Time
mode Mode

style Style
results results.Model
help results.Model
quit results.Model
input textinput.Model
}

type App struct {
Engine engine.Engine
Format format.Format
Expand All @@ -59,15 +32,8 @@ func (x *App) Run(ctx context.Context) error {
input.Placeholder = "Query"

model := Model{
qm: manager.New(
ctx,
x.Engine,
manager.WithSingleOpts(x.SingleOpts),
manager.WithRangeOpts(x.RangeOpts),
manager.WithWrite(x.Write)),

log: x.Log,
mode: modeScroll,
log: x.Log,

style: Style{
results: lip.NewStyle().
Expand All @@ -77,10 +43,21 @@ func (x *App) Run(ctx context.Context) error {
Border(lip.RoundedBorder()).
Padding(0, 1),
},
results: results.New(results.WithFormat(x.Format), results.WithLogger(x.Log)),
help: newHelp(),
quit: newQuit(),
input: input,

results: results.New(
results.WithFormat(x.Format),
results.WithLogger(x.Log)),

help: newHelp(),
quit: newQuit(),
input: input,

qm: manager.New(
ctx,
x.Engine,
manager.WithSingleOpts(x.SingleOpts),
manager.WithRangeOpts(x.RangeOpts),
manager.WithWrite(x.Write)),
}

_, err := tea.NewProgram(
Expand All @@ -91,3 +68,30 @@ func (x *App) Run(ctx context.Context) error {
).Run()
return err
}

type Mode int

const (
modeScroll Mode = iota
modeInput
modeHelp
modeQuit
)

type Style struct {
results lip.Style
input lip.Style
}

type Model struct {
mode Mode
latest time.Time
log zerolog.Logger

style Style
results results.Model
help results.Model
quit results.Model
input textinput.Model
qm manager.QueryManager
}

0 comments on commit af79e85

Please sign in to comment.