CLI Progress Bar Setup
Configure cli-progress for advanced progress indication.
Capabilities
- Configure single and multi-bar progress
- Create custom bar formatters
- Set up ETA calculations
- Implement payload data display
- Create progress bar presets
- Generate progress utilities
Usage
Invoke this skill when you need to:
- Show download/upload progress
- Display multi-task progress
- Create custom progress formats
- Implement ETA calculations
Inputs
| Parameter |
Type |
Required |
Description |
| language |
string |
Yes |
Target language |
| format |
string |
No |
Bar format template |
| presets |
array |
No |
Progress bar presets |
Generated Patterns
TypeScript Progress Utilities
import cliProgress, { SingleBar, MultiBar, Presets } from 'cli-progress';
import chalk from 'chalk';
// Custom format with colors
const defaultFormat = chalk.cyan('{bar}') +
' {percentage}% | ETA: {eta}s | {value}/{total} | {filename}';
// Create single progress bar
export function createProgressBar(options?: {
format?: string;
barSize?: number;
}): SingleBar {
return new SingleBar({
format: options?.format || defaultFormat,
barCompleteChar: '\u2588',
barIncompleteChar: '\u2591',
barsize: options?.barSize || 40,
hideCursor: true,
clearOnComplete: false,
stopOnComplete: true,
}, Presets.shades_classic);
}
// Multi-bar for parallel tasks
export function createMultiBar(): MultiBar {
return new MultiBar({
format: '{name} |' + chalk.cyan('{bar}') + '| {percentage}% | {value}/{total}',
barCompleteChar: '\u2588',
barIncompleteChar: '\u2591',
hideCursor: true,
clearOnComplete: false,
stopOnComplete: false,
}, Presets.shades_grey);
}
// Download progress with speed
export function createDownloadBar(): SingleBar {
return new SingleBar({
format: 'Downloading |' + chalk.cyan('{bar}') +
'| {percentage}% | {speed} MB/s | {value}/{total} MB',
barCompleteChar: '\u2588',
barIncompleteChar: '\u2591',
barsize: 30,
formatValue: (value, options, type) => {
if (type === 'value' || type === 'total') {
return (value / 1024 / 1024).toFixed(2);
}
return String(value);
},
}, Presets.shades_classic);
}
// Wrapper for async operations
export async function withProgress<T>(
total: number,
fn: (update: (current: number, payload?: Record<string, any>) => void) => Promise<T>,
options?: { format?: string }
): Promise<T> {
const bar = createProgressBar(options);
bar.start(total, 0);
try {
const result = await fn((current, payload) => {
bar.update(current, payload);
});
bar.stop();
return result;
} catch (error) {
bar.stop();
throw error;
}
}
// Batch processing with progress
export async function processBatch<T, R>(
items: T[],
processor: (item: T, index: number) => Promise<R>,
options?: { label?: string }
): Promise<R[]> {
const bar = createProgressBar({
format: `${options?.label || 'Processing'} |{bar}| {percentage}% | {value}/{total}`,
});
bar.start(items.length, 0);
const results: R[] = [];
for (let i = 0; i < items.length; i++) {
results.push(await processor(items[i], i));
bar.update(i + 1);
}
bar.stop();
return results;
}
// Parallel processing with multi-bar
export async function processParallel<T, R>(
tasks: Array<{
name: string;
items: T[];
processor: (item: T) => Promise<R>;
}>
): Promise<Map<string, R[]>> {
const multiBar = createMultiBar();
const bars = new Map<string, SingleBar>();
const results = new Map<string, R[]>();
// Create bars for each task
for (const task of tasks) {
const bar = multiBar.create(task.items.length, 0, { name: task.name.padEnd(15) });
bars.set(task.name, bar);
results.set(task.name, []);
}
// Process all tasks in parallel
await Promise.all(tasks.map(async (task) => {
const bar = bars.get(task.name)!;
const taskResults = results.get(task.name)!;
for (let i = 0; i < task.items.length; i++) {
taskResults.push(await task.processor(task.items[i]));
bar.update(i + 1);
}
}));
multiBar.stop();
return results;
}
Dependencies
{
"dependencies": {
"cli-progress": "^3.12.0",
"chalk": "^5.0.0"
},
"devDependencies": {
"@types/cli-progress": "^3.11.0"
}
}
Target Processes
- progress-status-indicators
- cli-output-formatting
- cli-application-bootstrap
1---
2name: cli-progress-bar-setup
3description: Configure cli-progress with custom formatters, multi-bar support, and ETA calculations for CLI progress indication.
4allowed-tools: Read, Write, Edit, Bash, Glob, Grep
5graph:
6 domains: [domain:software-engineering]
7 specializations: [specialization:cli-mcp-development]
8 skillAreas: [skill-area:cli-design, skill-area:command-line-interface-tools]
9 roles: [role:backend-engineer, role:platform-engineer]
10 workflows: [workflow:feature-development]
11 topics: [topic:developer-experience]
12
13metadata:
14 source: https://skillmd.com/skills/a5c-ai/cli-progress-bar-setup
15---
16
17# CLI Progress Bar Setup
18
19Configure cli-progress for advanced progress indication.
20
21## Capabilities
22
23- Configure single and multi-bar progress
24- Create custom bar formatters
25- Set up ETA calculations
26- Implement payload data display
27- Create progress bar presets
28- Generate progress utilities
29
30## Usage
31
32Invoke this skill when you need to:
33- Show download/upload progress
34- Display multi-task progress
35- Create custom progress formats
36- Implement ETA calculations
37
38## Inputs
39
40| Parameter | Type | Required | Description |
41|-----------|------|----------|-------------|
42| language | string | Yes | Target language |
43| format | string | No | Bar format template |
44| presets | array | No | Progress bar presets |
45
46## Generated Patterns
47
48### TypeScript Progress Utilities
49
50```typescript
51import cliProgress, { SingleBar, MultiBar, Presets } from 'cli-progress';
52import chalk from 'chalk';
53
54// Custom format with colors
55const defaultFormat = chalk.cyan('{bar}') +
56 ' {percentage}% | ETA: {eta}s | {value}/{total} | {filename}';
57
58// Create single progress bar
59export function createProgressBar(options?: {
60 format?: string;
61 barSize?: number;
62}): SingleBar {
63 return new SingleBar({
64 format: options?.format || defaultFormat,
65 barCompleteChar: '\u2588',
66 barIncompleteChar: '\u2591',
67 barsize: options?.barSize || 40,
68 hideCursor: true,
69 clearOnComplete: false,
70 stopOnComplete: true,
71 }, Presets.shades_classic);
72}
73
74// Multi-bar for parallel tasks
75export function createMultiBar(): MultiBar {
76 return new MultiBar({
77 format: '{name} |' + chalk.cyan('{bar}') + '| {percentage}% | {value}/{total}',
78 barCompleteChar: '\u2588',
79 barIncompleteChar: '\u2591',
80 hideCursor: true,
81 clearOnComplete: false,
82 stopOnComplete: false,
83 }, Presets.shades_grey);
84}
85
86// Download progress with speed
87export function createDownloadBar(): SingleBar {
88 return new SingleBar({
89 format: 'Downloading |' + chalk.cyan('{bar}') +
90 '| {percentage}% | {speed} MB/s | {value}/{total} MB',
91 barCompleteChar: '\u2588',
92 barIncompleteChar: '\u2591',
93 barsize: 30,
94 formatValue: (value, options, type) => {
95 if (type === 'value' || type === 'total') {
96 return (value / 1024 / 1024).toFixed(2);
97 }
98 return String(value);
99 },
100 }, Presets.shades_classic);
101}
102
103// Wrapper for async operations
104export async function withProgress<T>(
105 total: number,
106 fn: (update: (current: number, payload?: Record<string, any>) => void) => Promise<T>,
107 options?: { format?: string }
108): Promise<T> {
109 const bar = createProgressBar(options);
110 bar.start(total, 0);
111
112 try {
113 const result = await fn((current, payload) => {
114 bar.update(current, payload);
115 });
116 bar.stop();
117 return result;
118 } catch (error) {
119 bar.stop();
120 throw error;
121 }
122}
123
124// Batch processing with progress
125export async function processBatch<T, R>(
126 items: T[],
127 processor: (item: T, index: number) => Promise<R>,
128 options?: { label?: string }
129): Promise<R[]> {
130 const bar = createProgressBar({
131 format: `${options?.label || 'Processing'} |{bar}| {percentage}% | {value}/{total}`,
132 });
133
134 bar.start(items.length, 0);
135 const results: R[] = [];
136
137 for (let i = 0; i < items.length; i++) {
138 results.push(await processor(items[i], i));
139 bar.update(i + 1);
140 }
141
142 bar.stop();
143 return results;
144}
145
146// Parallel processing with multi-bar
147export async function processParallel<T, R>(
148 tasks: Array<{
149 name: string;
150 items: T[];
151 processor: (item: T) => Promise<R>;
152 }>
153): Promise<Map<string, R[]>> {
154 const multiBar = createMultiBar();
155 const bars = new Map<string, SingleBar>();
156 const results = new Map<string, R[]>();
157
158 // Create bars for each task
159 for (const task of tasks) {
160 const bar = multiBar.create(task.items.length, 0, { name: task.name.padEnd(15) });
161 bars.set(task.name, bar);
162 results.set(task.name, []);
163 }
164
165 // Process all tasks in parallel
166 await Promise.all(tasks.map(async (task) => {
167 const bar = bars.get(task.name)!;
168 const taskResults = results.get(task.name)!;
169
170 for (let i = 0; i < task.items.length; i++) {
171 taskResults.push(await task.processor(task.items[i]));
172 bar.update(i + 1);
173 }
174 }));
175
176 multiBar.stop();
177 return results;
178}
179```
180
181## Dependencies
182
183```json
184{
185 "dependencies": {
186 "cli-progress": "^3.12.0",
187 "chalk": "^5.0.0"
188 },
189 "devDependencies": {
190 "@types/cli-progress": "^3.11.0"
191 }
192}
193```
194
195## Target Processes
196
197- progress-status-indicators
198- cli-output-formatting
199- cli-application-bootstrap