Per-project configuration overwrites

Signed-off-by: Hadi <112569860+anotherhadi@users.noreply.github.com>
This commit is contained in:
Hadi
2026-05-30 00:14:54 +02:00
parent 77b102791f
commit 9d0ef598a7
5 changed files with 97 additions and 14 deletions
+24 -14
View File
@@ -99,21 +99,26 @@ func main() {
}
config.Global.Version = version
if flagPluginsDir != "" {
config.Global.App.PluginsDir = flagPluginsDir
}
if flagHost != "" {
config.Global.App.Host = flagHost
}
if flagPort != 0 {
config.Global.App.Port = flagPort
}
if flagUpstreamProxy != "" {
config.Global.App.UpstreamProxy = flagUpstreamProxy
}
if cmd.Flags().Changed("ssl-insecure") {
config.Global.App.SslInsecure = flagSslInsecure
sslInsecureChanged := cmd.Flags().Changed("ssl-insecure")
applyCLI := func(c *config.Config) {
if flagPluginsDir != "" {
c.App.PluginsDir = flagPluginsDir
}
if flagHost != "" {
c.App.Host = flagHost
}
if flagPort != 0 {
c.App.Port = flagPort
}
if flagUpstreamProxy != "" {
c.App.UpstreamProxy = flagUpstreamProxy
}
if sslInsecureChanged {
c.App.SslInsecure = flagSslInsecure
}
}
applyCLI(config.Global)
config.SetCLIOverrides(applyCLI)
style.Init()
icons.Init(config.Global)
@@ -126,6 +131,11 @@ func main() {
if err != nil {
return fmt.Errorf("project: %w", err)
}
if err := config.MergeProjectConfig(filepath.Dir(project.Path)); err != nil {
return fmt.Errorf("project config: %w", err)
}
icons.Init(config.Global)
keys.Init(config.Global)
broker := intercept.NewBroker()
m := appUI.New(broker, project.Name, project.Path)
final, err := tea.NewProgram(m).Run()
+11
View File
@@ -1,8 +1,14 @@
package main
import (
"log"
"path/filepath"
tea "charm.land/bubbletea/v2"
"github.com/anotherhadi/spilltea/internal/config"
"github.com/anotherhadi/spilltea/internal/icons"
"github.com/anotherhadi/spilltea/internal/intercept"
"github.com/anotherhadi/spilltea/internal/keys"
appUI "github.com/anotherhadi/spilltea/internal/ui/app"
homeUI "github.com/anotherhadi/spilltea/internal/ui/home"
)
@@ -34,6 +40,11 @@ func (m rootModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
if m.state == rootStateHome {
if sel, ok := msg.(homeUI.ProjectSelectedMsg); ok {
if err := config.MergeProjectConfig(filepath.Dir(sel.Project.Path)); err != nil {
log.Printf("project config: %v", err)
}
icons.Init(config.Global)
keys.Init(config.Global)
broker := intercept.NewBroker()
app := appUI.New(broker, sel.Project.Name, sel.Project.Path)
m.app = app