feat(spin): --show-stdout --show-stderr (#774)
Before adoption: this commit came in with the history the project adopted, so no landing records it.
closes #362
authored by Carlos Alexandro Becker · committed by GitHub · parent d1bfd56 · Browse files · 3 files·+18 added−9 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
3 files+18 added−9 removed
- other:+18 added−9 removed
Provenance
- Commit
32786f7- Tree
c34ac18- Author
Carlos Alexandro Becker <caarlos0@users.noreply.github.com>- Committer
GitHub <noreply@github.com>- Parent
d1bfd56
3 files changed+18 added−9 removed
modified:spin/command.go+2 added-1 removed
22 unmodified lines23 spinner: s,24 title: o.TitleStyle.ToLipgloss().Render(o.Title),25 command: o.Command,26 align: o.Align,27- showOutput: o.ShowOutput && isTTY,27+ showStdout: (o.ShowOutput || o.ShowStdout) && isTTY,28+ showStderr: (o.ShowOutput || o.ShowStderr) && isTTY,29 showError: o.ShowError,30 isTTY: isTTY,31 }32 43 unmodified linesmodified:spin/options.go+3 added-1 removed
8 unmodified lines9 // Options is the customization options for the spin command.10 type Options struct {11 Command []string `arg:"" help:"Command to run"`12 13- ShowOutput bool `help:"Show or pipe output of command during execution" default:"false" env:"GUM_SPIN_SHOW_OUTPUT"`13+ ShowOutput bool `help:"Show or pipe output of command during execution (shows both STDOUT and STDERR)" default:"false" env:"GUM_SPIN_SHOW_OUTPUT"`14 ShowError bool `help:"Show output of command only if the command fails" default:"false" env:"GUM_SPIN_SHOW_ERROR"`15+ ShowStdout bool `help:"Show STDOUT output" default:"false" env:"GUM_SPIN_SHOW_STDOUT"`16+ ShowStderr bool `help:"Show STDERR errput" default:"false" env:"GUM_SPIN_SHOW_STDERR"`17 Spinner string `help:"Spinner type" short:"s" type:"spinner" enum:"line,dot,minidot,jump,pulse,points,globe,moon,monkey,meter,hamburger" default:"dot" env:"GUM_SPIN_SPINNER"`18 SpinnerStyle style.Styles `embed:"" prefix:"spinner." set:"defaultForeground=212" envprefix:"GUM_SPIN_SPINNER_"`19 Title string `help:"Text to display to user while spinning" default:"Loading..." env:"GUM_SPIN_TITLE"`20 TitleStyle style.Styles `embed:"" prefix:"title." envprefix:"GUM_SPIN_TITLE_"`3 unmodified linesmodified:spin/spin.go+13 added-7 removed
35 unmodified lines36 status int37 stdout string38 stderr string39 output string40- showOutput bool40+ showStdout bool41+ showStderr bool42 showError bool43 }44 45 var (60 unmodified lines106 if !m.isTTY {107 return m.title108 }109 109- if m.quitting && m.showOutput {110- return strings.TrimPrefix(errbuf.String()+"\n"+outbuf.String(), "\n")110+ var out string111+ if m.showStderr {112+ out += errbuf.String()113 }114+ if m.showStdout {115+ out += outbuf.String()116+ }117 118+ if m.quitting && out != "" {119+ return out120+ }121+122 var header string123 if m.align == "left" {124 header = m.spinner.View() + " " + m.title125 } else {126 header = m.title + " " + m.spinner.View()127 }119- if !m.showOutput {120- return header128+ return header + "\n" + out121- }122- return header + errbuf.String() + "\n" + outbuf.String()129 }130 131 func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {132 var cmd tea.Cmd18 unmodified lines