Get the FREE Ultimate OpenClaw Setup Guide →

cli-progress-bar-setup

npx machina-cli add skill a5c-ai/babysitter/cli-progress-bar-setup --openclaw
Files (1)
SKILL.md
4.6 KB

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

ParameterTypeRequiredDescription
languagestringYesTarget language
formatstringNoBar format template
presetsarrayNoProgress 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

Source

git clone https://github.com/a5c-ai/babysitter/blob/main/plugins/babysitter/skills/babysit/process/specializations/cli-mcp-development/skills/cli-progress-bar-setup/SKILL.mdView on GitHub

Overview

Configure cli-progress for advanced CLI progress indication. It enables single and multi-bar progress, custom bar formatters, ETA calculations, and payload data displays, plus presets and utilities to simplify common progress patterns.

How This Skill Works

The skill exposes TypeScript utilities like createProgressBar, createMultiBar, and specialized bars (download, etc.) built on cli-progress SingleBar and MultiBar. It provides wrappers such as withProgress, processBatch, and processParallel to drive updates and display payload data as tasks advance.

When to Use It

  • Showing download or upload progress in CLI utilities.
  • Tracking multiple tasks running in parallel with separate bars.
  • Creating custom, branded progress formats for a consistent UX.
  • Calculating and displaying ETA, speed, and payload data during long runs.
  • Batch or parallel processing tasks with progress feedback during processing.

Quick Start

  1. Step 1: Install dependencies (cli-progress and chalk) and import them.
  2. Step 2: Create progress utilities using createProgressBar, createMultiBar, and presets.
  3. Step 3: Drive updates using withProgress, processBatch, or processParallel and call bar.update/stop appropriately.

Best Practices

  • Use SingleBar for linear tasks and MultiBar for parallel tasks.
  • Leverage presets for consistent visuals across bars.
  • Include meaningful labels and payload updates for context.
  • Always stop bars on completion and handle errors to clean up UI.
  • Test formatting at different totals to ensure readability.

Example Use Cases

  • Download progress bar with speed and ETA using createDownloadBar.
  • Display multiple simultaneous downloads/uploads with createMultiBar.
  • Wrap an async operation with withProgress to track completion.
  • Process a batch of items with processBatch and a labeled bar.
  • Run parallel tasks with processParallel and per-task bars.

Frequently Asked Questions

Add this skill to your agents
Sponsor this space

Reach thousands of developers