Skip to content

Commit

Permalink
fix: allow run in non-interactive mode (#816)
Browse files Browse the repository at this point in the history
  • Loading branch information
tjholm authored Nov 4, 2024
1 parent a9b7d65 commit 89b7b9f
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions cmd/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"fmt"
"os"
"os/signal"
"strings"
"syscall"

tea "github.com/charmbracelet/bubbletea"
Expand Down Expand Up @@ -124,10 +125,24 @@ var runCmd = &cobra.Command{

allBuildUpdates := lo.FanIn(10, updates, batchBuildUpdates)

prog := teax.NewProgram(build.NewModel(allBuildUpdates, "Building Services"))
// blocks but quits once the above updates channel is closed by the build process
_, err = prog.Run()
tui.CheckErr(err)
if isNonInteractive() {
fmt.Println("building project services")
for _, service := range proj.GetServices() {
fmt.Printf("service matched '%s', auto-naming this service '%s'\n", service.GetFilePath(), service.Name)
}

// non-interactive environment
for update := range allBuildUpdates {
for _, line := range strings.Split(strings.TrimSuffix(update.Message, "\n"), "\n") {
fmt.Printf("%s [%s]: %s\n", update.ServiceName, update.Status, line)
}
}
} else {
prog := teax.NewProgram(build.NewModel(allBuildUpdates, "Building Services"))
// blocks but quits once the above updates channel is closed by the build process
_, err = prog.Run()
tui.CheckErr(err)
}

// Run the app code (project services)
stopChan := make(chan bool)
Expand Down

0 comments on commit 89b7b9f

Please sign in to comment.