Skip to content

Commit f883397

Browse files
committed
fix: always use stderr when prompt choice
1 parent 1ed55d0 commit f883397

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

internal/utils/flags/project_ref.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,7 @@ func ParseProjectRef(ctx context.Context, fsys afero.Fs) error {
2222
}
2323
// Prompt as the last resort
2424
if term.IsTerminal(int(os.Stdin.Fd())) {
25-
// Interactive prompts should always be written to stderr
26-
opts := []tea.ProgramOption{tea.WithOutput(os.Stderr)}
27-
return PromptProjectRef(ctx, "Select a project:", opts...)
25+
return PromptProjectRef(ctx, "Select a project:")
2826
}
2927
return errors.New(utils.ErrNotLinked)
3028
}

internal/utils/prompt.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"context"
55
"fmt"
66
"io"
7+
"os"
78
"strings"
89

910
"github.com/charmbracelet/bubbles/list"
@@ -123,6 +124,8 @@ func PromptChoice(ctx context.Context, title string, items []PromptItem, opts ..
123124
// Create our model
124125
ctx, cancel := context.WithCancel(ctx)
125126
initial := model{cancel: cancel, list: l}
127+
// Interactive prompts should always be written to stderr
128+
opts = append(opts, tea.WithOutput(os.Stderr))
126129
prog := tea.NewProgram(initial, opts...)
127130
state, err := prog.Run()
128131
if err != nil {

0 commit comments

Comments
 (0)