Skip to content

Commit 2182dde

Browse files
committed
fix some stray terminal query output
1 parent 45ba512 commit 2182dde

File tree

6 files changed

+19
-1
lines changed

6 files changed

+19
-1
lines changed

cmd/dbc/auth.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,8 @@ type authSuccessMsg struct {
8888
cred auth.Credential
8989
}
9090

91+
func (loginModel) NeedsRenderer() {}
92+
9193
type loginModel struct {
9294
baseModel
9395

cmd/dbc/install.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,8 @@ func (s installState) String() string {
148148
}
149149
}
150150

151+
func (progressiveInstallModel) NeedsRenderer() {}
152+
151153
type progressiveInstallModel struct {
152154
baseModel
153155

cmd/dbc/main.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,13 @@ type HasStatus interface {
5959
Err() error
6060
}
6161

62+
// NeedsRenderer is implemented by models that render a live TUI (spinners,
63+
// progress bars, interactive lists). Models that only use tea.Println /
64+
// tea.Printf and return an empty View do not need the renderer.
65+
type NeedsRenderer interface {
66+
NeedsRenderer()
67+
}
68+
6269
// use this so we can override this in tests
6370
var getDriverRegistry = dbc.GetDriverList
6471

@@ -218,7 +225,8 @@ func main() {
218225
// }
219226
// defer f.Close()
220227

221-
if !isatty.IsTerminal(os.Stdout.Fd()) {
228+
_, needsRenderer := m.(NeedsRenderer)
229+
if !isatty.IsTerminal(os.Stdout.Fd()) || !needsRenderer {
222230
prog = tea.NewProgram(m, tea.WithoutRenderer(), tea.WithInput(nil))
223231
} else if args.Quiet {
224232
// Quiet still prints stderr as GNU standard is to suppress "usual" output

cmd/dbc/sync.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ func (c SyncCmd) GetModel() tea.Model {
6464
}
6565
}
6666

67+
func (syncModel) NeedsRenderer() {}
68+
6769
type syncModel struct {
6870
baseModel
6971

cmd/dbc/tui_driver_list.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ func (i item) Title() string { return i.d.Title }
4242
func (i item) Description() string { return i.d.Desc }
4343
func (i item) FilterValue() string { return i.d.Title }
4444

45+
func (model) NeedsRenderer() {}
46+
4547
type model struct {
4648
Prev tea.Model
4749

cmd/dbc/tui_menu.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ func getTuiModel() tea.Model {
4646
return m
4747
}
4848

49+
func (menu) NeedsRenderer() {}
50+
4951
type menu struct {
5052
options list.Model
5153
}

0 commit comments

Comments
 (0)