Skip to content

edisoncks/cli-loading-indicator

 
 

Repository files navigation

cli-loading-indicator Test NPM Version

Animated command line loading indicator using Unicode braille patterns (based on Heroku CLI).

size rotation preview sample code
large cw examples/formatted.js
small ccw examples/formatted-multicolor.js

Usage

  • Use start() and stop() to enable or disable the loading indicator.
  • Optionally specify rotation as cw (clockwise) or ccw (counterclockwise)
  • Optionally provide a custom format function to add text or colors for the loading indicator.
// ESM
import LoadingIndicator from "@edisoncks/cli-loading-indicator";

// CommonJS
const LoadingIndicator = require("@edisoncks/cli-loading-indicator").default;

const loader = new LoadingIndicator({
  size: "large",
  rotation: "cw",
  format: (pattern) => `charging plasma cannon ${pattern}`,
});

// Display loading indicator for 5 seconds, and then stop.
loader.start();
setTimeout(() => {
  loader.stop();
}, 5000);

Compatibility

This library uses ANSI escape sequences for cursor control and animation. Supported terminals include:

  • Linux — gnome-terminal, konsole, xterm, Alacritty, Kitty, WezTerm
  • macOS — terminal.app, iTerm2, Alacritty, Kitty
  • Windows — Windows Terminal

Limited or no support:

  • Legacy Windows Console — cmd.exe, PowerShell (before Windows 10 1903). DEC private modes (?25l/h) were not supported in older environments.

Credits

Heavily inspired by heroku cli loading indicator

About

Animated command line loading indicator using Unicode braille patterns ⠾ ⠽ ⠻ ⠯ ⠷

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages

  • TypeScript 95.9%
  • JavaScript 4.1%