Improve output formatting for databases commands#1565
Conversation
Visual overhaul of all `stripe databases` commands to match design spec:
Table (list):
- Remove Host column; show ID and colored status indicators (● Active, ○ Backfilling)
- Unicode ─ separators with ASCII fallback on Windows
- Bold white headers, muted ID column
- Name column commented out pending API display_name field
Retrieve:
- Split into two blocks: instance metadata (Status, API Version, Mode, Created)
then Connection details (Host, Port, Database)
- "View in Dashboard:" in muted text with indented clickable URL
- Full database ID always shown (no truncation)
Create:
- Progress steps (✓ Provisioned, ✓ Generated credentials, ○ Syncing data...)
with 30ms staggered display and correct color tokens
- Password warning uses em dash: "Save this password now — it will not be shown again."
- Dashboard URL uses /test/ prefix for test-mode databases
- Current status line: status colored by value, retrieve command in cyan
- Legal disclaimer with "Privacy Policy" and "Preview Terms" in bold,
surrounding text faint; privacy/terms URLs as clickable OSC-8 links
General:
- Every command output starts and ends with a blank line
- Delete confirmation prompt includes ⚠ glyph and leading blank line
- Phrase changed to "delete database"
- Users retrieve: full IDs shown (no truncation)
- Users delete: clean "Deleted {id}" without parenthetical name
- textBoldCyan labels throughout connection detail blocks
- tableColumn abstraction replaces printAlignedTable for cleaner column definitions
- databaseUnicodeSupported() gates Unicode glyphs on Windows
Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
Committed-By-Agent: claude
7dea20d to
9b4c11a
Compare
| func printTable(out io.Writer, columns []tableColumn, rowCount int, emptyMessage string) { | ||
| if rowCount == 0 { |
There was a problem hiding this comment.
should probably move this out to its own file but don't want to change how the code is currently structured as this is the only consumer
mattmueller-stripe
left a comment
There was a problem hiding this comment.
requesting changes specifically to remove the warning. everything else is nice-to-have.
Strong suggestion to update some of our command examples to include how to get the url/password:
Prior art:
Line 29 in bda2142
Can be added here and a few of the other commands:
stripe-cli/pkg/cmd/resource/databases.go
Line 253 in bda2142
Can definitely be a follow-up though.
| func runDatabaseCreate(cmd *cobra.Command, opCmd *OperationCmd, args []string) error { | ||
| var sp *spinner.Spinner | ||
| if !jsonOutputEnabled(cmd) { | ||
| sp = ansi.StartNewSpinner("Creating StripeDB instance...", cmd.ErrOrStderr()) |
| fmt.Fprintf(out, "Created StripeDB instance %s\n", database.ID) | ||
|
|
||
| // Leading blank line to match design spec | ||
| fmt.Fprintln(out) |
There was a problem hiding this comment.
nit/ooc: do other cli commands have tests?
I feel like we should probably be doing something like:
type CLI struct {
Stdout io.Writer // defaults to os.Stdout, but can be overriden for testing
}
func (c *CLI) runDatabaseCreate(...) {
fmt.Fprintln(c.Stdout, "blah blah")
}There was a problem hiding this comment.
ah, nevermind, looks like cobra has this built-in with cmd.OutOrStdout()
| databaseJSONFlagName = "json" | ||
| databaseRequestVersion = "unsafe-development" | ||
| databaseDeleteConfirmationPhrase = "remove StripeDB" | ||
| databaseDeleteConfirmationPhrase = "delete database" |
| if user.Password != "" { | ||
| fmt.Fprintln(out) | ||
| fmt.Fprintf(out, " %s %s. %s stripe databases retrieve %s\n", | ||
| fmt.Fprintln(out, textYellow(out, databaseWarningGlyph()+" Save this password now — it will not be shown again.")) |
| termsURL := "https://stripe.com/stripe-database-preview-terms" | ||
| fmt.Fprintf(out, " %s\n", ansi.Linkify(privacyURL, privacyURL, out)) | ||
| fmt.Fprintf(out, " %s\n", ansi.Linkify(termsURL, termsURL, out)) | ||
|
|
Summary
Updates the pretty-print output for all
stripe databasescommands to be more scannable and consistent.● Active,○ Backfilling), Unicode separators, muted secondary columnsView in Dashboardwith clickable URL on supporting terminalsChanges
tableColumn+printTableabstraction replacesprintAlignedTable— each column owns its data extraction and styling, no more parallel arraysvisualWidth()strips ANSI sequences before measuring column padding so colored cells align correctlydatabaseUnicodeSupported()gates Unicode glyphs on Windows (falls back to ASCII oncmd.exe, passes through on Windows Terminal)databaseWarningGlyph()anddatabaseRelativeTimeAgo()helpers eliminate duplicationTest plan
go test ./pkg/cmd/resource/ -run TestDatabasepasses