File tree Expand file tree Collapse file tree 3 files changed +23
-8
lines changed
Expand file tree Collapse file tree 3 files changed +23
-8
lines changed Original file line number Diff line number Diff line change @@ -275,6 +275,10 @@ var devCommand = cli.Command{
275275}
276276
277277func runPreview (ctx context.Context , cmd * cli.Command ) error {
278+ // Clear the screen and move the cursor to the top
279+ fmt .Print ("\033 [2J\033 [H" )
280+ os .Stdout .Sync ()
281+
278282 cc := getAPICommandContext (cmd )
279283
280284 gitUser , err := getGitUsername ()
Original file line number Diff line number Diff line change @@ -2,12 +2,14 @@ package cmd
22
33import (
44 "fmt"
5+ "os"
56 "strings"
67 "time"
78
89 tea "github.com/charmbracelet/bubbletea"
910 "github.com/charmbracelet/glamour"
1011 "github.com/charmbracelet/lipgloss"
12+ "github.com/charmbracelet/x/term"
1113 "github.com/stainless-api/stainless-api-go"
1214)
1315
@@ -293,10 +295,15 @@ func ViewHelpMenu() string {
293295
294296// renderMarkdown renders markdown content using glamour
295297func renderMarkdown (content string ) string {
298+ width , _ , err := term .GetSize (uintptr (os .Stdout .Fd ()))
299+ if err != nil || width <= 0 || width > 120 {
300+ width = 120
301+ }
296302 r , err := glamour .NewTermRenderer (
297303 glamour .WithAutoStyle (),
298- glamour .WithWordWrap (120 ),
304+ glamour .WithWordWrap (width ),
299305 )
306+
300307 if err != nil {
301308 return content
302309 }
Original file line number Diff line number Diff line change @@ -41,6 +41,10 @@ var lintCommand = cli.Command{
4141 Action : runLinter ,
4242}
4343
44+ var helpStyle = lipgloss .NewStyle ().
45+ Foreground (lipgloss .Color ("241" )).
46+ Margin (1 , 0 , 0 , 0 )
47+
4448type lintModel struct {
4549 spinner spinner.Model
4650 diagnostics []stainless.BuildDiagnostic
@@ -88,13 +92,19 @@ func waitForFileChanges(m lintModel) tea.Cmd {
8892}
8993
9094func (m lintModel ) Init () tea.Cmd {
95+ if m .watching {
96+ // Clear the screen and move the cursor to the top
97+ fmt .Print ("\033 [2J\033 [H" )
98+ os .Stdout .Sync ()
99+ }
91100 return m .spinner .Tick
92101}
93102
94103func (m lintModel ) Update (msg tea.Msg ) (tea.Model , tea.Cmd ) {
95104 switch msg := msg .(type ) {
96105 case tea.KeyMsg :
97106 if msg .String () == "ctrl+c" {
107+ m .watching = false
98108 return m , tea .Quit
99109 }
100110
@@ -143,13 +153,7 @@ func (m lintModel) View() string {
143153 }
144154 }
145155
146- // Add help menu
147- helpStyle := lipgloss .NewStyle ().
148- Foreground (lipgloss .Color ("241" )).
149- Margin (1 , 0 , 0 , 0 )
150-
151156 helpText := helpStyle .Render ("Press Ctrl+C to exit" )
152-
153157 return content + helpText
154158}
155159
@@ -221,7 +225,7 @@ func runLinter(ctx context.Context, cmd *cli.Command) error {
221225 }
222226
223227 // If not in watch mode and we have blocking diagnostics, exit with error code
224- if ! finalModel . watching && hasBlockingDiagnostic (finalModel .diagnostics ) {
228+ if ! cmd . Bool ( "watch" ) && hasBlockingDiagnostic (finalModel .diagnostics ) {
225229 os .Exit (1 )
226230 }
227231
You can’t perform that action at this time.
0 commit comments