Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
leg100 committed Apr 2, 2024
1 parent c7c3505 commit 7c30ee0
Show file tree
Hide file tree
Showing 22 changed files with 262 additions and 95 deletions.
14 changes: 9 additions & 5 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ require (
github.com/charmbracelet/bubbles v0.18.0
github.com/charmbracelet/bubbletea v0.25.0
github.com/charmbracelet/lipgloss v0.9.1
github.com/charmbracelet/x/exp/teatest v0.0.0-20240329185201-62a6965a9fad
github.com/davecgh/go-spew v1.1.1
github.com/go-logfmt/logfmt v0.6.0
github.com/mattn/go-runewidth v0.0.15
Expand All @@ -32,7 +33,10 @@ require (
github.com/apparentlymart/go-textseg/v13 v13.0.0 // indirect
github.com/apparentlymart/go-textseg/v15 v15.0.0 // indirect
github.com/apparentlymart/go-versions v1.0.1 // indirect
github.com/atotto/clipboard v0.1.4 // indirect
github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect
github.com/aymanbagabas/go-udiff v0.2.0 // indirect
github.com/charmbracelet/x/exp/golden v0.0.0-20240222125807-0344fda748f8 // indirect
github.com/containerd/console v1.0.4-0.20230313162750-1ae8d489ac81 // indirect
github.com/fatih/color v1.7.0 // indirect
github.com/golang/protobuf v1.4.3 // indirect
Expand All @@ -47,11 +51,11 @@ require (
github.com/hashicorp/terraform-svchost v0.0.0-20200729002733-f050f53b9734 // indirect
github.com/lucasb-eyer/go-colorful v1.2.0 // indirect
github.com/mattn/go-colorable v0.1.4 // indirect
github.com/mattn/go-isatty v0.0.18 // indirect
github.com/mattn/go-isatty v0.0.19 // indirect
github.com/mattn/go-localereader v0.0.1 // indirect
github.com/mitchellh/go-wordwrap v1.0.0 // indirect
github.com/mitchellh/panicwrap v1.0.0 // indirect
github.com/muesli/ansi v0.0.0-20211018074035-2e021307bc4b // indirect
github.com/muesli/ansi v0.0.0-20230316100256-276c6243b2f6 // indirect
github.com/muesli/cancelreader v0.2.2 // indirect
github.com/muesli/termenv v0.15.2 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
Expand All @@ -61,9 +65,9 @@ require (
golang.org/x/mod v0.14.0 // indirect
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2 // indirect
golang.org/x/oauth2 v0.0.0-20200902213428-5d25da1a8d43 // indirect
golang.org/x/sys v0.12.0 // indirect
golang.org/x/term v0.6.0 // indirect
golang.org/x/text v0.11.0 // indirect
golang.org/x/sys v0.17.0 // indirect
golang.org/x/term v0.11.0 // indirect
golang.org/x/text v0.12.0 // indirect
google.golang.org/appengine v1.6.6 // indirect
google.golang.org/protobuf v1.25.0 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
Expand Down
28 changes: 18 additions & 10 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,15 @@ github.com/armon/circbuf v0.0.0-20190214190532-5111143e8da2/go.mod h1:3U/XgcO3hC
github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da/go.mod h1:Q73ZrmVTwzkszR9V5SSuryQ31EELlFMUz1kKyl939pY=
github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8=
github.com/armon/go-radix v1.0.0/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8=
github.com/atotto/clipboard v0.1.4 h1:EH0zSVneZPSuFR11BlR9YppQTVDbh5+16AmcJi4g1z4=
github.com/atotto/clipboard v0.1.4/go.mod h1:ZY9tmq7sm5xIbd9bOK4onWV4S6X0u6GY7Vn0Yu86PYI=
github.com/aws/aws-sdk-go v1.15.78/go.mod h1:E3/ieXAlvM0XWO57iftYVDLLvQ824smPP3ATZkfNZeM=
github.com/aws/aws-sdk-go v1.31.9/go.mod h1:5zCpMtNQVjRREroY7sYe8lOMRSxkhG6MZveU8YkpAk0=
github.com/aws/aws-sdk-go v1.37.0/go.mod h1:hcU610XS61/+aQV88ixoOzUoG7v3b31pl2zKMmprdro=
github.com/aymanbagabas/go-osc52/v2 v2.0.1 h1:HwpRHbFMcZLEVr42D4p7XBqjyuxQH5SMiErDT4WkJ2k=
github.com/aymanbagabas/go-osc52/v2 v2.0.1/go.mod h1:uYgXzlJ7ZpABp8OJ+exZzJJhRNQ2ASbcXHWsFqH8hp8=
github.com/aymanbagabas/go-udiff v0.2.0 h1:TK0fH4MteXUDspT88n8CKzvK0X9O2xu9yQjWpi6yML8=
github.com/aymanbagabas/go-udiff v0.2.0/go.mod h1:RE4Ex0qsGkTAJoQdQQCA0uG+nAzJO/pI/QwceO5fgrA=
github.com/baiyubin/aliyun-sts-go-sdk v0.0.0-20180326062324-cfa1a18b161f/go.mod h1:AuiFmCCPBSrqvVMvuqFuk0qogytodnVFVSN5CeJB8Gc=
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d/go.mod h1:6QX/PXZ00z/TKoufEY6K/a0k6AhaJrQKdFe6OfVXsa4=
Expand All @@ -123,6 +127,10 @@ github.com/charmbracelet/bubbletea v0.25.0 h1:bAfwk7jRz7FKFl9RzlIULPkStffg5k6pNt
github.com/charmbracelet/bubbletea v0.25.0/go.mod h1:EN3QDR1T5ZdWmdfDzYcqOCAps45+QIJbLOBxmVNWNNg=
github.com/charmbracelet/lipgloss v0.9.1 h1:PNyd3jvaJbg4jRHKWXnCj1akQm4rh8dbEzN1p/u1KWg=
github.com/charmbracelet/lipgloss v0.9.1/go.mod h1:1mPmG4cxScwUQALAAnacHaigiiHB9Pmr+v1VEawJl6I=
github.com/charmbracelet/x/exp/golden v0.0.0-20240222125807-0344fda748f8 h1:kyT+aGp1z5jwlus3OY0cP6FuT05jYeeExx/4TYxnyrs=
github.com/charmbracelet/x/exp/golden v0.0.0-20240222125807-0344fda748f8/go.mod h1:wDlXFlCrmJ8J+swcL/MnGUuYnqgQdW9rhSD61oNMb6U=
github.com/charmbracelet/x/exp/teatest v0.0.0-20240329185201-62a6965a9fad h1:7NyOJ06kOnx24u3Qx5WWaLz9wP6lBP1B49celRIH/78=
github.com/charmbracelet/x/exp/teatest v0.0.0-20240329185201-62a6965a9fad/go.mod h1:SG24wGkG/mix5V2dZLXfQ6Bod43HGvk9CkTDxATwKN4=
github.com/cheggaaa/pb v1.0.27/go.mod h1:pQciLPpbU0oxA0h+VJYYLxO+XeDQb5pZijXscXHm81s=
github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI=
github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI=
Expand Down Expand Up @@ -367,8 +375,8 @@ github.com/mattn/go-isatty v0.0.4/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNx
github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
github.com/mattn/go-isatty v0.0.10/go.mod h1:qgIWMr58cqv1PHHyhnkY9lrL7etaEgOFcMEpPG5Rm84=
github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
github.com/mattn/go-isatty v0.0.18 h1:DOKFKCQ7FNG2L1rbrmstDN4QVRdS89Nkh85u68Uwp98=
github.com/mattn/go-isatty v0.0.18/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
github.com/mattn/go-isatty v0.0.19 h1:JITubQf0MOLdlGRuRq+jtsDlekdYPia9ZFsB8h/APPA=
github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
github.com/mattn/go-localereader v0.0.1 h1:ygSAOl7ZXTx4RdPYinUpg6W99U8jWvWi9Ye2JC/oIi4=
github.com/mattn/go-localereader v0.0.1/go.mod h1:8fBrzywKY7BI3czFoHkuzRoWE9C+EiG4R1k4Cjx5p88=
github.com/mattn/go-shellwords v1.0.4/go.mod h1:3xCvwCdWdlDJUrvuMn7Wuy9eWs4pE8vqg+NOMyg4B2o=
Expand Down Expand Up @@ -399,8 +407,8 @@ github.com/modern-go/reflect2 v0.0.0-20180320133207-05fbef0ca5da/go.mod h1:bx2lN
github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
github.com/mozillazg/go-httpheader v0.2.1/go.mod h1:jJ8xECTlalr6ValeXYdOF8fFUISeBAdw6E61aqQma60=
github.com/muesli/ansi v0.0.0-20211018074035-2e021307bc4b h1:1XF24mVaiu7u+CFywTdcDo2ie1pzzhwjt6RHqzpMU34=
github.com/muesli/ansi v0.0.0-20211018074035-2e021307bc4b/go.mod h1:fQuZ0gauxyBcmsdE3ZT4NasjaRdxmbCS0jRHsrWu3Ho=
github.com/muesli/ansi v0.0.0-20230316100256-276c6243b2f6 h1:ZK8zHtRHOkbHy6Mmr5D264iyp3TiX5OmNcI5cIARiQI=
github.com/muesli/ansi v0.0.0-20230316100256-276c6243b2f6/go.mod h1:CJlz5H+gyd6CUWT45Oy4q24RdLyn7Md9Vj2/ldJBSIo=
github.com/muesli/cancelreader v0.2.2 h1:3I4Kt4BQjOR54NavqnDogx/MIoWBFa0StPA8ELUXHmA=
github.com/muesli/cancelreader v0.2.2/go.mod h1:3XuTXfFS2VjM+HTLZY9Ak0l6eUKfijIfMUZ4EgX0QYo=
github.com/muesli/termenv v0.15.2 h1:GohcuySI0QmI3wN8Ok9PtKGkgkFIk7y6Vpb5PvrY+Wo=
Expand Down Expand Up @@ -665,13 +673,13 @@ golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7w
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.12.0 h1:CM0HF96J0hcLAwsHPJZjfdNzs0gftsLfgKt57wWHJ0o=
golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.17.0 h1:25cE3gD+tdBA7lp7QfhuV+rJiE9YXTcS3VG1SqssI/Y=
golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20201210144234-2321bbc49cbf/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.6.0 h1:clScbb1cHjoCkyRbWwBEUZ5H/tIFu5TAXIqaZD0Gcjw=
golang.org/x/term v0.6.0/go.mod h1:m6U89DPEgQRMq3DNkDClhWw02AUbt2daBVO4cn4Hv9U=
golang.org/x/term v0.11.0 h1:F9tnn/DA/Im8nCwm+fX+1/eBwi4qFjRT++MhtVC4ZX0=
golang.org/x/term v0.11.0/go.mod h1:zC9APTIj3jG3FdV/Ons+XE1riIZXG4aZ4GTHiPZJPIU=
golang.org/x/text v0.0.0-20160726164857-2910a502d2bf/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
Expand All @@ -680,8 +688,8 @@ golang.org/x/text v0.3.1-0.20181227161524-e6919f6577db/go.mod h1:bEr9sfX3Q8Zfm5f
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.11.0 h1:LAntKIrcmeSKERyiOh0XMV39LXS8IE9UL2yP7+f5ij4=
golang.org/x/text v0.11.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
golang.org/x/text v0.12.0 h1:k+n5B8goJNdU7hSvEtMUz3d1Q6D/XW4COJSJR6fN0mc=
golang.org/x/text v0.12.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
Expand Down
2 changes: 1 addition & 1 deletion internal/module/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ type ServiceOptions struct {
func NewService(opts ServiceOptions) *Service {
broker := pubsub.NewBroker[*Module]()
svc := &Service{
table: resource.NewTable[*Module](broker),
table: resource.NewTable(broker),
broker: broker,
tasks: opts.TaskService,
workdir: opts.Workdir,
Expand Down
5 changes: 2 additions & 3 deletions internal/tui/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"github.com/leg100/pug/internal/resource"
"github.com/leg100/pug/internal/run"
"github.com/leg100/pug/internal/task"
"github.com/leg100/pug/internal/workspace"
)

// CreateTasks returns a command that creates one or more tasks using the given
Expand Down Expand Up @@ -36,7 +35,7 @@ func WaitTasks(created CreatedTasksMsg) tea.Cmd {
}
}

func CreateRuns(runs *run.Service, workspaceIDs ...resource.ID) tea.Cmd {
func CreateRuns(runs RunService, workspaceIDs ...resource.ID) tea.Cmd {
if len(workspaceIDs) == 0 {
return nil
}
Expand Down Expand Up @@ -73,7 +72,7 @@ func OpenVim(path string) tea.Cmd {
})
}

func ReloadModules(workspaces *workspace.Service) tea.Cmd {
func ReloadModules(workspaces WorkspaceService) tea.Cmd {
return func() tea.Msg {
multi, errs := workspaces.ReloadAll()
return CreatedTasksMsg{
Expand Down
9 changes: 4 additions & 5 deletions internal/tui/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
"github.com/leg100/pug/internal/module"
"github.com/leg100/pug/internal/resource"
"github.com/leg100/pug/internal/run"
"github.com/leg100/pug/internal/state"
"github.com/leg100/pug/internal/workspace"
)

Expand All @@ -21,10 +20,10 @@ import (
// table with, say 40 visible rows, means they are invoked 40 times a render,
// which is 40 lookups.
type Helpers struct {
ModuleService *module.Service
WorkspaceService *workspace.Service
RunService *run.Service
StateService *state.Service
ModuleService ModuleService
WorkspaceService WorkspaceService
RunService RunService
StateService StateService
}

func (h *Helpers) ModulePath(res resource.Resource) string {
Expand Down
12 changes: 6 additions & 6 deletions internal/tui/module/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ var (

// ListMaker makes module list models
type ListMaker struct {
ModuleService *module.Service
WorkspaceService *workspace.Service
RunService *run.Service
ModuleService tui.ModuleService
WorkspaceService tui.WorkspaceService
RunService tui.RunService
Spinner *spinner.Model
Workdir string
Helpers *tui.Helpers
Expand Down Expand Up @@ -103,9 +103,9 @@ func (m *ListMaker) Make(_ resource.Resource, width, height int) (tui.Model, err
}

type list struct {
ModuleService *module.Service
WorkspaceService *workspace.Service
RunService *run.Service
ModuleService tui.ModuleService
WorkspaceService tui.WorkspaceService
RunService tui.RunService

table table.Resource[resource.ID, *module.Module]
spinner *spinner.Model
Expand Down
12 changes: 5 additions & 7 deletions internal/tui/module/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,11 @@ import (
tea "github.com/charmbracelet/bubbletea"
"github.com/leg100/pug/internal/module"
"github.com/leg100/pug/internal/resource"
"github.com/leg100/pug/internal/run"
"github.com/leg100/pug/internal/tui"
"github.com/leg100/pug/internal/tui/keys"
runtui "github.com/leg100/pug/internal/tui/run"
tasktui "github.com/leg100/pug/internal/tui/task"
workspacetui "github.com/leg100/pug/internal/tui/workspace"
"github.com/leg100/pug/internal/workspace"
)

const (
Expand All @@ -24,9 +22,9 @@ const (

// Maker makes module models.
type Maker struct {
ModuleService *module.Service
WorkspaceService *workspace.Service
RunService *run.Service
ModuleService tui.ModuleService
WorkspaceService tui.WorkspaceService
RunService tui.RunService

WorkspaceListMaker *workspacetui.ListMaker
RunListMaker *runtui.ListMaker
Expand Down Expand Up @@ -66,8 +64,8 @@ func (mm *Maker) Make(mr resource.Resource, width, height int) (tui.Model, error
}

type model struct {
ModuleService *module.Service
RunService *run.Service
ModuleService tui.ModuleService
RunService tui.RunService

module *module.Module
tabs tui.TabSet
Expand Down
14 changes: 6 additions & 8 deletions internal/tui/run/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,12 @@ import (
"github.com/charmbracelet/bubbles/key"
tea "github.com/charmbracelet/bubbletea"
"github.com/charmbracelet/lipgloss"
"github.com/leg100/pug/internal/module"
"github.com/leg100/pug/internal/resource"
"github.com/leg100/pug/internal/run"
"github.com/leg100/pug/internal/task"
"github.com/leg100/pug/internal/tui"
"github.com/leg100/pug/internal/tui/keys"
"github.com/leg100/pug/internal/tui/table"
"github.com/leg100/pug/internal/workspace"
)

var ageColumn = table.Column{
Expand All @@ -26,10 +24,10 @@ var ageColumn = table.Column{
}

type ListMaker struct {
ModuleService *module.Service
WorkspaceService *workspace.Service
RunService *run.Service
TaskService *task.Service
ModuleService tui.ModuleService
WorkspaceService tui.WorkspaceService
RunService tui.RunService
TaskService tui.TaskService
Helpers *tui.Helpers
}

Expand Down Expand Up @@ -83,8 +81,8 @@ func (m *ListMaker) Make(parent resource.Resource, width, height int) (tui.Model

type list struct {
table table.Resource[resource.ID, *run.Run]
svc *run.Service
tasks *task.Service
svc tui.RunService
tasks tui.TaskService
parent resource.Resource
}

Expand Down
8 changes: 4 additions & 4 deletions internal/tui/run/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ import (
)

type Maker struct {
RunService *run.Service
TaskService *task.Service
RunService tui.RunService
TaskService tui.TaskService
Spinner *spinner.Model
Helpers *tui.Helpers
}
Expand Down Expand Up @@ -61,8 +61,8 @@ func (mm *Maker) Make(rr resource.Resource, width, height int) (tui.Model, error
}

type model struct {
svc *run.Service
tasks *task.Service
svc tui.RunService
tasks tui.TaskService
run *run.Run
tabs tui.TabSet
taskMaker tui.Maker
Expand Down
45 changes: 45 additions & 0 deletions internal/tui/services.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package tui

import (
"github.com/leg100/pug/internal/module"
"github.com/leg100/pug/internal/resource"
"github.com/leg100/pug/internal/run"
"github.com/leg100/pug/internal/state"
"github.com/leg100/pug/internal/task"
"github.com/leg100/pug/internal/workspace"
)

type ModuleService interface {
Get(id resource.ID) (*module.Module, error)
List() []*module.Module
Reload() error
Init(moduleID resource.ID) (*task.Task, error)
Format(moduleID resource.ID) (*task.Task, error)
Validate(moduleID resource.ID) (*task.Task, error)
}

type WorkspaceService interface {
ReloadAll() (task.Multi, []error)
Get(id resource.ID) (*workspace.Workspace, error)
List(opts workspace.ListOptions) []*workspace.Workspace
}

type StateService interface {
Reload(workspaceID resource.ID) (*task.Task, error)
Get(workspaceID resource.ID) (*state.State, error)
Delete(workspaceID resource.ID, addrs ...state.ResourceAddress) (*task.Task, error)
}

type RunService interface {
Create(workspaceID resource.ID, opts run.CreateOptions) (*run.Run, error)
Get(id resource.ID) (*run.Run, error)
List(opts run.ListOptions) []*run.Run
Apply(runID resource.ID) (*task.Task, error)
}

type TaskService interface {
Counter() int
Get(taskID resource.ID) (*task.Task, error)
List(opts task.ListOptions) []*task.Task
Cancel(taskID resource.ID) (*task.Task, error)
}
7 changes: 3 additions & 4 deletions internal/tui/table/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@ package table

import (
tea "github.com/charmbracelet/bubbletea"
"github.com/leg100/pug/internal/module"
"github.com/leg100/pug/internal/resource"
"github.com/leg100/pug/internal/workspace"
"github.com/leg100/pug/internal/tui"
)

// Resource is a wrapper of table.Model specifically for use with pug
Expand All @@ -16,8 +15,8 @@ type Resource[K resource.ID, V ResourceValue] struct {
}

type ResourceOptions[V ResourceValue] struct {
ModuleService *module.Service
WorkspaceService *workspace.Service
ModuleService tui.ModuleService
WorkspaceService tui.WorkspaceService
Columns []Column
Renderer RowRenderer[V]
Width, Height int
Expand Down
Loading

0 comments on commit 7c30ee0

Please sign in to comment.