Skip to content

Commit

Permalink
🚑 Fix loading the repositories properly from pinocchio
Browse files Browse the repository at this point in the history
  • Loading branch information
wesen committed Dec 31, 2024
1 parent 095428a commit 579e0c0
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
2 changes: 1 addition & 1 deletion cmd/prompto/cmds/serve.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,5 @@ func (s *ServeCommand) run(cmd *cobra.Command, args []string) error {
port, _ := cmd.Flags().GetInt("port")
watching, _ := cmd.Flags().GetBool("watching")

return server.Serve(port, watching)
return server.Serve(port, watching, s.repositories)
}
5 changes: 2 additions & 3 deletions pkg/server/serve.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import (
"github.com/go-go-golems/glazed/pkg/helpers/templating"
"github.com/go-go-golems/prompto/pkg"
"github.com/rs/zerolog/log"
"github.com/spf13/viper"
)

type ServerState struct {
Expand All @@ -34,7 +33,6 @@ func (s *ServerState) LoadRepositories() error {
s.mu.Lock()
defer s.mu.Unlock()

s.Repositories = viper.GetStringSlice("repositories")
for _, repoPath := range s.Repositories {
repo := pkg.NewRepository(repoPath)
err := repo.LoadPromptos()
Expand Down Expand Up @@ -179,8 +177,9 @@ func (s *ServerState) WatchRepositories(ctx context.Context) error {
return nil
}

func Serve(port int, watching bool) error {
func Serve(port int, watching bool, repositories []string) error {
state := NewServerState(watching)
state.Repositories = repositories
if err := state.LoadRepositories(); err != nil {
return fmt.Errorf("error loading repositories: %w", err)
}
Expand Down

0 comments on commit 579e0c0

Please sign in to comment.