Repository navigation
cli: terminal UI polish (capability detection, grouped help, error blocks, progress bar) - #11
Merged
Merged
Conversation
…ocks, progress bar) Everything here is for a person at a terminal. Piped, redirected, in CI, under NO_COLOR/CLICOLOR=0/TERM=dumb, and with --json or -q, stdout and stderr are byte-for-byte what they were: the golden tests pass unchanged, and 51 piped --help screens are identical to main's. internal/ui - Caps/Detect: 16 / 256 / 24-bit colour, UTF-8 locale, OSC 8 hyperlinks and a light background, read from the environment. Force keeps the old 16-colour UTF-8 profile, so existing tests and escape codes are unchanged. - Semantic roles (Accent, Success, Warn, Danger, Muted, Strong) instead of colour names. The signals stay in the terminal's own palette so a theme tunes them; only the accent (teal) and the amber leave it, to colours with contrast on black and on white. - Glyph sets with an ASCII fallback (+ x ! > ... and a | / - \ spinner). - Width, Truncate, Wrap and StripANSI measure terminal cells (wide characters, combining marks, escapes). Wrap keeps a long URL whole and keeps indentation. - Error block: the ERR:: code is muted so the sentence leads, the hint is the accent, keys align, long text wraps under its own column, URLs are linked. - The spinner measures the terminal every frame, so it follows a resize. New Spinner.Progress(done, total) draws a determinate bar with a count and an ETA, dropping the ETA, then the bar, then the label's tail as the line narrows. - Elapsed formats hours (1h05m). internal/cmd - help.go: spicrawl --help and <cmd> --help on a live terminal get grouped commands, coloured headings and names, muted defaults and API routes, wrapped descriptions and the docs link. Installed with SetHelpFunc from init(), so no command file changes. Anything not live gets cobra's help. - view.go: rows wrap under their value column and link URLs on a terminal, marks use the glyph set (warn is amber), tables measure cells.
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
A pass over everything a person sees at a terminal, built on the
internal/uibase from #4. Nothing a script or agent reads changes: piped, redirected, in CI, underNO_COLOR/CLICOLOR=0/TERM=dumb, and with--jsonor-q, the output is byte-for-byte what it was.ui.Caps): 16 / 256 / 24-bit colour, UTF-8 locale, OSC 8 hyperlinks, light background (COLORFGBG). Read fromTERM,COLORTERM,TERM_PROGRAM,WT_SESSION,VTE_VERSION,LC_ALL/LC_CTYPE/LANG,FORCE_HYPERLINK. The zeroCapsis the most conservative terminal;ui.Forcekeeps the old 16-colour UTF-8 profile, so existing tests and escape codes are unchanged.Accent,Success,Warn,Danger,Muted,Strong), not names. Signals stay in the terminal's own palette, so Solarized / Dracula / light themes tune them. Only the accent (teal) and the amber leave it, to colours with contrast on black and on white (the accent is 3.7:1 on white, 5.7:1 on black).✓ ✗ ! › · …become+ x ! > - ..., the spinner becomes| / - \.Width,Truncate,Wrap,StripANSIcount terminal cells (CJK and emoji are two, combining marks and escapes are none).Wrapnever splits a URL or id and keeps a line's indentation.ERR::code is muted so the sentence leads, thehintrow is the accent, keys align, long text wraps under its own column (not under the key), URLs are links where the terminal has them.Spinner.Progress(done, total)draws a determinate bar with count and ETA (⠹ Batch job ━━━━━━━━╸───────── 12/24 · 4.4s · ETA 4s), dropping the ETA, then the bar, then the label's tail as the line narrows. The ETA waits for 2 s and one finished item. Nothing calls it yet (see follow-ups).--helpon a live terminal: commands grouped by purpose, coloured headings and names, defaults and(GET /v1/...)routes muted, descriptions wrapped under their own column, an examples section (root examples are checked by a test to be real commands), docs link. Installed withSetHelpFuncfrom a newhelp.goinit(), so no command file and notroot.gochanged. Anything not live (and--json/-q) gets cobra's help.view.go: rows wrap and link on a terminal, marks use the glyph set (warn is amber, not just bold), tables measure cells. Signatures unchanged.No new dependencies (
golang.org/x/termandpflagwere already direct).Before and after (pty, 100 columns)
scrape https://example.com/blockedspicrawl --help(before: alphabetical, one flat list, a flag default wrapped mid-URL by the terminal)LC_ALL=C:{green}+{/} example.com {dim}200 - 1 credit - 2.5s{/}and a| / - \spinner.Verified
go vet ./...,gofmt -l,go test -race ./...pass. The golden suite (all cases, 0 fail) passes withtestdata/untouched.--helpis identical tomainfor all 51 command paths, and unchanged under a TTY withNO_COLOR,CI,TERM=dumb,CLICOLOR=0and--json/-q(a test locks the last two).GOOS/GOARCHbuilds: linux, darwin, windows x amd64, arm64;go vetfor windows and darwin.Width/Truncate/Wrap, bar and ETA,progressLinefits every width from 12 to 200 columns, a mid-run resize, error-block wrapping and links, help layout (every command listed once in one name column, sections in order, no internal engine names on any command's live help, root examples parse).Known limits
Follow-ups that need files outside this PR
root.go(problemRows): add{Key: "docs", Val: prob.DocURL}(the API sendsdoc_url); the error block already links it. Also therequestrow says the id twice (01J9... (spicrawl logs get 01J9...));spicrawl logs get 01J9...alone is enough.batch_wait.go: callspin.Progress(done, total)sobatch wait/submit --waitshow the bar and ETA. Keep the label to the job id, since the count moves to the bar.status.go(✗/✓at the summary lines),auth.go(✓/✗verdicts),sessions.go(✓ Session created),agents.go(✓/–cells and the·join). UseviewMark(u, markOK)/u.Glyphs().logs.go,sessions.go: spinner labels with a literal·should useu.Glyphs().Dot.auth.go:u.Cyan(authKeysURL)can beu.Link(authKeysURL, "").ui.Cyanstays as an alias ofAccentso nothing in flight breaks; new code should use the role names.