Skip to content

jaywcjlove/loading-cli

Repository files navigation

loading-cli

Buy me a coffee CI

Terminal loading effect.

Install

$ npm install --save loading-cli

Usage

const loading =  require('loading-cli');
const load = loading("loading text!!").start()

setTimeout(function(){
    load.color = 'yellow';
    load.text = ' Loading rainbows';
},2000)

// stop
setTimeout(function(){
    load.stop()
},3000)

Custom text color colors-cli

const color = require('colors-cli/toxic');
const loading = require('loading-cli');

const load = loading("loading text!!".blue).start();
// stop
setTimeout(function(){
  load.stop()
},3000)

API

loading([options|text])

options

load({
  "text":"loading text!!",
  "color":"yellow",
  "interval":100,
  "stream": process.stdout,
  "frames":["◰", "◳", "◲", "◱"]
})

text

Type: string Text to display after the spinner.

loading("loading text!!")

color

Values:black red green yellow blue magenta cyan white gray

frames

["", "", "", ""]
["", "", "", ""]
[".", "o", "O", "°", "O", "o", "."]
["", ""]
["", ""]
["", "", "", "", "", "", "", ""]
["🕐 ", "🕑 ", "🕒 ", "🕓 ", "🕔 ", "🕕 ", "🕖 ", "🕗 ", "🕘 ", "🕙 ", "🕚 "]

Instance

.start([text])

Start the spinner. Returns the instance.

.stop()

Stop and clear the spinner. Returns the instance.

.clear()

Clear the spinner. Returns the instance.

.succeed([text])

Stop the spinner, change it to a green and persist the current text, or text if provided. Returns the instance. See the GIF below.

.fail([text])

Stop the spinner, change it to a red and persist the current text, or text if provided. Returns the instance. See the GIF below.

.warn([text])

Stop the spinner, change it to a yellow and persist the current text, or text if provided. Returns the instance.

.info([text])

Stop the spinner, change it to a blue and persist the current text, or text if provided. Returns the instance.

.render()

Manually render a new frame. Returns the instance.

.frame()

Get a new frame.

const loading = require('loading-cli');
const load = loading("loading text!!");
load.frame(["◰", "◳", "◲", "◱"]);
load.start();

.text

Change the text.

.color

Change the spinner color.

Contributors

As always, thanks to our amazing contributors!

Made with contributors.

License

Licensed under the MIT License.