@@ -5,6 +5,7 @@ import (
55 "database/sql"
66 "errors"
77 "fmt"
8+ "io"
89 "log/slog"
910 "sync"
1011 "time"
@@ -103,7 +104,7 @@ func (app *App) Config() *config.Config {
103104
104105// RunNonInteractive runs the application in non-interactive mode with the
105106// given prompt, printing to stdout.
106−func (app *App) RunNonInteractive(ctx context.Context, prompt string, quiet bool) error {
107+func (app *App) RunNonInteractive(ctx context.Context, output io.Writer, prompt string, quiet bool) error {
107108 slog.Info("Running in non-interactive mode")
108109
109110 ctx, cancel := context.WithCancel(ctx)
@@ -170,7 +171,7 @@ func (app *App) RunNonInteractive(ctx context.Context, prompt string, quiet bool
170171
171172 // Always print a newline at the end. If output is a TTY this will
172173 // prevent the prompt from overwriting the last line of output.
173− _, _ = fmt.Print('\n')
174+ _, _ = fmt.Fprintln(output)
174175 }()
175176
176177 for {
@@ -204,7 +205,7 @@ func (app *App) RunNonInteractive(ctx context.Context, prompt string, quiet bool
204205 }
205206
206207 part := content[readBytes:]
207− fmt.Print(part)
208+ fmt.Fprint(output, part)
208209 messageReadBytes[msg.ID] = len(content)
209210 }
210211