-
-
Notifications
You must be signed in to change notification settings - Fork 1
feat: beautiful CLI with box-drawing, progress bar, and readable output #134
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
85ccb5d
fix: replace shimmer with readable progress text
rubenmarcus 4fa7a3a
feat: add progress bar and box-drawing utilities
rubenmarcus 0c2817a
feat: box-drawing headers, startup summary, and completion banner
rubenmarcus af1546c
feat: add status separators and compact validation feedback
rubenmarcus File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,68 @@ | ||
| import chalk, { type ChalkInstance } from 'chalk'; | ||
|
|
||
| /** | ||
| * Get terminal width with a sensible fallback | ||
| */ | ||
| export function getTerminalWidth(): number { | ||
| return process.stdout.columns || 80; | ||
| } | ||
|
|
||
| /** | ||
| * Draw a box with box-drawing characters around content lines | ||
| */ | ||
| export function drawBox( | ||
| lines: string[], | ||
| options: { color?: ChalkInstance; width?: number } = {} | ||
| ): string { | ||
| const color = options.color || chalk.cyan; | ||
| const width = options.width || Math.min(60, getTerminalWidth() - 4); | ||
| const innerWidth = width - 2; | ||
|
|
||
| const output: string[] = []; | ||
| output.push(color(`┌${'─'.repeat(innerWidth)}┐`)); | ||
|
|
||
| for (const line of lines) { | ||
| // Strip ANSI codes to measure real length | ||
| // biome-ignore lint/suspicious/noControlCharactersInRegex: ANSI escape sequence detection requires control characters | ||
| const stripped = line.replace(/\u001b\[[0-9;]*m/g, ''); | ||
| const padding = Math.max(0, innerWidth - stripped.length); | ||
| output.push(color('│') + line + ' '.repeat(padding) + color('│')); | ||
| } | ||
|
|
||
| output.push(color(`└${'─'.repeat(innerWidth)}┘`)); | ||
| return output.join('\n'); | ||
| } | ||
|
|
||
| /** | ||
| * Draw a horizontal separator with an optional centered label | ||
| */ | ||
| export function drawSeparator(label?: string, width?: number): string { | ||
| const w = width || Math.min(60, getTerminalWidth() - 4); | ||
|
|
||
| if (!label) { | ||
| return chalk.dim('─'.repeat(w)); | ||
| } | ||
|
|
||
| const labelLen = label.length + 2; // space on each side | ||
| const sideLen = Math.max(1, Math.floor((w - labelLen) / 2)); | ||
| const left = '─'.repeat(sideLen); | ||
| const right = '─'.repeat(w - sideLen - labelLen); | ||
| return chalk.dim(`${left} ${label} ${right}`); | ||
| } | ||
|
|
||
| /** | ||
| * Render a progress bar | ||
| */ | ||
| export function renderProgressBar( | ||
| current: number, | ||
| total: number, | ||
| options: { width?: number; label?: string } = {} | ||
| ): string { | ||
| const barWidth = options.width || 20; | ||
| const ratio = Math.min(1, Math.max(0, current / total)); | ||
| const filled = Math.round(ratio * barWidth); | ||
| const empty = barWidth - filled; | ||
| const bar = `${'█'.repeat(filled)}${'░'.repeat(empty)}`; | ||
| const info = options.label ? ` │ ${options.label}` : ''; | ||
| return `${chalk.cyan(bar)} ${current}/${total}${chalk.dim(info)}`; | ||
| } | ||
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
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Division by zero produces an empty progress bar.
When
totalis 0, the ratio calculation results inNaN, causing bothfilledandemptyto beNaN. WhileString.prototype.repeathandles this gracefully (returning empty strings), the progress bar will appear empty rather than showing a meaningful state.🛡️ Proposed fix to handle zero total
export function renderProgressBar( current: number, total: number, options: { width?: number; label?: string } = {} ): string { const barWidth = options.width || 20; - const ratio = Math.min(1, Math.max(0, current / total)); + const ratio = total > 0 ? Math.min(1, Math.max(0, current / total)) : 0; const filled = Math.round(ratio * barWidth);📝 Committable suggestion
🤖 Prompt for AI Agents