fix(spin): if not a tty, only print title, do not open tty for stdin

closes #328
This commit is contained in:
Carlos Alexandro Becker 2024-12-10 21:47:00 -03:00
commit 2741e2eebb
No known key found for this signature in database

View file

@ -26,16 +26,22 @@ func (o Options) Run() error {
align: o.Align,
showOutput: o.ShowOutput && isTTY,
showError: o.ShowError,
isTTY: isTTY,
}
ctx, cancel := timeout.Context(o.Timeout)
defer cancel()
tm, err := tea.NewProgram(
m,
opts := []tea.ProgramOption{
tea.WithOutput(os.Stderr),
tea.WithContext(ctx),
).Run()
}
if !isTTY {
opts = append(opts, tea.WithInput(nil))
}
tm, err := tea.NewProgram(m, opts...).Run()
if err != nil {
return fmt.Errorf("unable to run action: %w", err)
}