@@ -99,7 +99,6 @@ type Config struct {
InitialAdminKeys []string `env:"INITIAL_ADMIN_KEY" envSeparator:"\n"`
Callbacks Callbacks
- ErrorLog *log.Logger
db db.Store
}
@@ -124,8 +123,8 @@ func (c *Config) PrivateKeyPath() string {
func DefaultConfig() *Config {
var err error
var migrateWarn bool
- cfg := &Config{ErrorLog: log.Default()}
- if err = env.Parse(cfg, env.Options{
+ var cfg Config
+ if err = env.Parse(&cfg, env.Options{
Prefix: "SOFT_SERVE_",
}); err != nil {
log.Fatalln(err)
@@ -170,12 +169,6 @@ func (c *Config) WithCallbacks(callbacks Callbacks) *Config {
return c
}
-// WithErrorLogger sets the error logger for the configuration.
-func (c *Config) WithErrorLogger(logger *log.Logger) *Config {
- c.ErrorLog = logger
- return c
-}
-
// WithDB sets the database for the configuration.
func (c *Config) WithDB(db db.Store) *Config {
c.db = db
@@ -35,7 +35,7 @@ func NewServer(cfg *config.Config) *Server {
s := &Server{Config: cfg}
mw := []wish.Middleware{
rm.MiddlewareWithLogger(
- cfg.ErrorLog,
+ log.Default(),
// BubbleTea middleware.
bm.MiddlewareWithProgramHandler(SessionHandler(cfg), termenv.ANSI256),
// Command middleware must come after the git middleware.
@@ -10,12 +10,9 @@ import (
"github.com/charmbracelet/soft-serve/server/config"
"github.com/charmbracelet/soft-serve/ui"
"github.com/charmbracelet/soft-serve/ui/common"
- "github.com/charmbracelet/soft-serve/ui/keymap"
- "github.com/charmbracelet/soft-serve/ui/styles"
"github.com/charmbracelet/wish"
bm "github.com/charmbracelet/wish/bubbletea"
"github.com/gliderlabs/ssh"
- zone "github.com/lrstanley/bubblezone"
)
// SessionHandler is the soft-serve bubbletea ssh session handler.
@@ -41,20 +38,9 @@ func SessionHandler(cfg *config.Config) bm.ProgramHandler {
envs := s.Environ()
envs = append(envs, fmt.Sprintf("TERM=%s", pty.Term))
output := osc52.NewOutput(s, envs)
- c := common.Common{
- Copy: output,
- Styles: styles.DefaultStyles(),
- KeyMap: keymap.DefaultKeyMap(),
- Width: pty.Window.Width,
- Height: pty.Window.Height,
- Zone: zone.New(),
- }
- m := ui.New(
- cfg,
- s,
- c,
- initialRepo,
- )
+ c := common.NewCommon(s.Context(), output, pty.Window.Width, pty.Window.Height)
+ c.SetValue(common.ConfigKey, cfg)
+ m := ui.New(c, initialRepo)
p := tea.NewProgram(m,
tea.WithInput(s),
tea.WithOutput(s),