@@ -5,6 +5,7 @@ import (
5 "database/sql"
5 "database/sql"
@@ -103,7 +104,7 @@ func (app *App) Config() *config.Config {
104// RunNonInteractive runs the application in non-interactive mode with the
105// RunNonInteractive runs the application in non-interactive mode with the
105// given prompt, printing to stdout.
106// 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 {
107 slog.Info("Running in non-interactive mode")
108 slog.Info("Running in non-interactive mode")
109 ctx, cancel := context.WithCancel(ctx)
110 ctx, cancel := context.WithCancel(ctx)
@@ -170,7 +171,7 @@ func (app *App) RunNonInteractive(ctx context.Context, prompt string, quiet bool
171 // Always print a newline at the end. If output is a TTY this will
172 // Always print a newline at the end. If output is a TTY this will
172 // prevent the prompt from overwriting the last line of output.
173 // prevent the prompt from overwriting the last line of output.
173− _, _ = fmt.Print('\n')
174+ _, _ = fmt.Fprintln(output)
@@ -204,7 +205,7 @@ func (app *App) RunNonInteractive(ctx context.Context, prompt string, quiet bool
206 part := content[readBytes:]
207 part := content[readBytes:]
207− fmt.Print(part)
208+ fmt.Fprint(output, part)
208 messageReadBytes[msg.ID] = len(content)
209 messageReadBytes[msg.ID] = len(content)