Skip to content

Commit 0fb7fa2

Browse files
author
Bruce Hill
committed
Cap the width of the "Next steps" dialog at the end
1 parent 231df48 commit 0fb7fa2

File tree

1 file changed

+19
-6
lines changed

1 file changed

+19
-6
lines changed

pkg/cmd/init.go

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import (
1212

1313
"github.com/charmbracelet/huh"
1414
"github.com/charmbracelet/lipgloss"
15+
"github.com/charmbracelet/x/term"
1516
"github.com/pkg/browser"
1617
"github.com/stainless-api/stainless-api-cli/pkg/jsonflag"
1718
"github.com/stainless-api/stainless-api-go"
@@ -359,15 +360,27 @@ func initializeWorkspace(ctx context.Context, cmd *cli.Command, cc *apiCommandCo
359360

360361
Spacer()
361362

363+
// Get terminal width or use a sensible default
364+
width, _, err := term.GetSize(os.Stderr.Fd())
365+
if err != nil {
366+
width = 100
367+
} else if width > 100 {
368+
width = 100
369+
}
370+
362371
fmt.Fprintf(
363372
os.Stderr,
364373
"%s\n",
365-
lipgloss.NewStyle().Border(lipgloss.RoundedBorder()).Padding(0, 1).Render(
366-
"Next steps:\n\n"+
367-
" * See "+lipgloss.NewStyle().Foreground(lipgloss.Color("14")).Render("https://www.stainless.com/docs/guides/configure")+" to learn how to customize your SDKs\n\n"+
368-
" * Use "+lipgloss.NewStyle().Foreground(lipgloss.Color("14")).Render("stl builds create")+" to create more builds\n"+
369-
" * Use "+lipgloss.NewStyle().Foreground(lipgloss.Color("14")).Render("stl dev")+" to launch a development server that helps you build and see output locally.",
370-
),
374+
lipgloss.NewStyle().
375+
Border(lipgloss.RoundedBorder()).
376+
Padding(0, 1).
377+
Width(width-2).
378+
Render(
379+
"Next steps:\n\n"+
380+
" * See "+lipgloss.NewStyle().Foreground(lipgloss.Color("14")).Render("https://www.stainless.com/docs/guides/configure")+" to learn how to customize your SDKs\n\n"+
381+
" * Use "+lipgloss.NewStyle().Foreground(lipgloss.Color("14")).Render("stl builds create")+" to create more builds\n"+
382+
" * Use "+lipgloss.NewStyle().Foreground(lipgloss.Color("14")).Render("stl dev")+" to launch a development server that helps you build and see output locally.",
383+
),
371384
)
372385

373386
return nil

0 commit comments

Comments
 (0)