Skip to content

Commit 5bf3734

Browse files
author
Bruce Hill
committed
Clear the screen between --watch runs in stl preview
1 parent 54c4231 commit 5bf3734

File tree

3 files changed

+20
-6
lines changed

3 files changed

+20
-6
lines changed

pkg/cmd/dev.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -387,6 +387,12 @@ func runPreview(ctx context.Context, cmd *cli.Command) error {
387387
if !cmd.Bool("watch") {
388388
break
389389
}
390+
391+
// Clear the screen and move the cursor to the top
392+
fmt.Print("\nRebuilding...\n\n\033[2J\033[H")
393+
os.Stdout.Sync()
394+
Property("branch", selectedBranch)
395+
Property("targets", strings.Join(selectedTargets, ", "))
390396
}
391397
return nil
392398
}

pkg/cmd/dev_view.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,10 +105,10 @@ var parts = []struct {
105105
},
106106
},
107107
{
108-
name: "diagnostics",
108+
name: "build diagnostics",
109109
view: func(m BuildModel, s *strings.Builder) {
110110
if m.diagnostics == nil {
111-
s.WriteString(SProperty(0, "diagnostics", "waiting for build to finish"))
111+
s.WriteString(SProperty(0, "build diagnostics", "(waiting for build to finish)"))
112112
} else {
113113
s.WriteString(ViewDiagnosticsPrint(m.diagnostics, 10))
114114
}
@@ -362,15 +362,15 @@ func ViewDiagnosticsPrint(diagnostics []stainless.BuildDiagnostic, maxDiagnostic
362362
}
363363
}
364364

365-
s.WriteString(SProperty(0, "diagnostics", summary))
365+
s.WriteString(SProperty(0, "build diagnostics", summary))
366366
s.WriteString(lipgloss.NewStyle().
367367
Padding(0).
368368
Border(lipgloss.RoundedBorder()).
369369
BorderForeground(lipgloss.Color("208")).
370370
Render(strings.TrimRight(sub.String(), "\n")),
371371
)
372372
} else {
373-
s.WriteString(SProperty(0, "diagnostics", "(no errors or warnings)"))
373+
s.WriteString(SProperty(0, "build diagnostics", "(no errors or warnings)"))
374374
}
375375

376376
return s.String()

pkg/cmd/lint.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ type lintModel struct {
5656
diagnostics []stainless.BuildDiagnostic
5757
error error
5858
watching bool
59+
skipped bool
5960
canSkip bool
6061
ctx context.Context
6162
cmd *cli.Command
@@ -77,6 +78,7 @@ func (m lintModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
7778
return m, tea.Quit
7879
} else if msg.String() == "enter" {
7980
m.watching = false
81+
m.skipped = true
8082
return m, tea.Quit
8183
}
8284

@@ -124,10 +126,16 @@ func (m lintModel) View() string {
124126
if m.error != nil {
125127
content = "Linting failed!"
126128
} else if m.diagnostics == nil {
127-
content = m.spinner.View() + " Linting"
129+
if m.skipped {
130+
content = "Skipped!"
131+
} else {
132+
content = m.spinner.View() + " Linting"
133+
}
128134
} else {
129135
content = ViewDiagnosticsPrint(m.diagnostics, -1)
130-
if m.watching {
136+
if m.skipped {
137+
content += "\nContinuing..."
138+
} else if m.watching {
131139
content += "\n" + m.spinner.View() + " Waiting for configuration changes"
132140
}
133141
}

0 commit comments

Comments
 (0)