tiki/internal/bootstrap/controllers.go
2026-01-17 11:08:53 -05:00

54 lines
1.5 KiB
Go

package bootstrap
import (
"github.com/rivo/tview"
"github.com/boolean-maybe/tiki/controller"
"github.com/boolean-maybe/tiki/model"
"github.com/boolean-maybe/tiki/plugin"
"github.com/boolean-maybe/tiki/store"
)
// Controllers holds all application controllers.
type Controllers struct {
Nav *controller.NavigationController
Board *controller.BoardController
Task *controller.TaskController
Plugins map[string]controller.PluginControllerInterface
}
// BuildControllers constructs navigation/domain/plugin controllers for the application.
func BuildControllers(
app *tview.Application,
taskStore store.Store,
boardConfig *model.BoardConfig,
plugins []plugin.Plugin,
pluginConfigs map[string]*model.PluginConfig,
) *Controllers {
navController := controller.NewNavigationController(app)
boardController := controller.NewBoardController(taskStore, boardConfig, navController)
taskController := controller.NewTaskController(taskStore, navController)
pluginControllers := make(map[string]controller.PluginControllerInterface)
for _, p := range plugins {
if tp, ok := p.(*plugin.TikiPlugin); ok {
pluginControllers[p.GetName()] = controller.NewPluginController(
taskStore,
pluginConfigs[p.GetName()],
tp,
navController,
)
continue
}
if dp, ok := p.(*plugin.DokiPlugin); ok {
pluginControllers[p.GetName()] = controller.NewDokiController(dp, navController)
}
}
return &Controllers{
Nav: navController,
Board: boardController,
Task: taskController,
Plugins: pluginControllers,
}
}