(fix): ShowOutput flag displays in realtime (#405)

This commit is contained in:
Rose Thatcher 2023-11-29 15:54:57 -06:00 committed by GitHub
parent 32c9d20692
commit 5c65944c66
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -24,6 +24,7 @@ func (o Options) Run() error {
title: o.TitleStyle.ToLipgloss().Render(o.Title),
command: o.Command,
align: o.Align,
showOutput: o.ShowOutput && isTTY,
timeout: o.Timeout,
hasTimeout: o.Timeout > 0,
}
@ -44,7 +45,9 @@ func (o Options) Run() error {
}
if o.ShowOutput {
if isTTY {
// BubbleTea writes the View() to stderr.
// If the program is being piped then put the accumulated output in stdout.
if !isTTY {
_, err := os.Stdout.WriteString(m.stdout)
if err != nil {
return fmt.Errorf("failed to write to stdout: %w", err)