(percent: number, width: number)
| 68 | |
| 69 | /** Create a progress bar */ |
| 70 | export function createProgressBar(percent: number, width: number): string { |
| 71 | const c = getChalk() |
| 72 | const p = Math.min(100, Math.max(0, percent)) |
| 73 | const filled = Math.round((p / 100) * width) |
| 74 | const empty = Math.max(0, width - filled) |
| 75 | |
| 76 | let barColor = c.green |
| 77 | if (p >= 80) { |
| 78 | barColor = c.red |
| 79 | } else if (p >= 60) { |
| 80 | barColor = c.yellow |
| 81 | } |
| 82 | |
| 83 | return `[${barColor('█'.repeat(filled))}${c.dim('░'.repeat(empty))}]` |
| 84 | } |
| 85 | |
| 86 | /** Display resource metrics inline */ |
| 87 | export function displayMetrics(metrics: JupyterMetricsResponse): void { |
no test coverage detected