mirror of
https://github.com/charmbracelet/gum
synced 2024-06-26 17:20:16 +02:00
(fix): ShowOutput flag displays in realtime (#405)
This commit is contained in:
parent
32c9d20692
commit
5c65944c66
|
@ -24,6 +24,7 @@ func (o Options) Run() error {
|
||||||
title: o.TitleStyle.ToLipgloss().Render(o.Title),
|
title: o.TitleStyle.ToLipgloss().Render(o.Title),
|
||||||
command: o.Command,
|
command: o.Command,
|
||||||
align: o.Align,
|
align: o.Align,
|
||||||
|
showOutput: o.ShowOutput && isTTY,
|
||||||
timeout: o.Timeout,
|
timeout: o.Timeout,
|
||||||
hasTimeout: o.Timeout > 0,
|
hasTimeout: o.Timeout > 0,
|
||||||
}
|
}
|
||||||
|
@ -44,7 +45,9 @@ func (o Options) Run() error {
|
||||||
}
|
}
|
||||||
|
|
||||||
if o.ShowOutput {
|
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)
|
_, err := os.Stdout.WriteString(m.stdout)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to write to stdout: %w", err)
|
return fmt.Errorf("failed to write to stdout: %w", err)
|
||||||
|
|
Loading…
Reference in a new issue