Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/jaywcjlove/loading-cli

Terminal loading effect.
https://github.com/jaywcjlove/loading-cli

cli loader loading loading-cli nodejs spinner terminal

Last synced: 27 days ago
JSON representation

Terminal loading effect.

Awesome Lists containing this project

README

        

# loading-cli

[![Buy me a coffee](https://img.shields.io/badge/Buy%20me%20a%20coffee-048754?logo=buymeacoffee)](https://jaywcjlove.github.io/#/sponsor)
[![](https://jaywcjlove.github.io/sb/ico/npm.svg)](https://www.npmjs.com/package/loading-cli)
[![CI](https://github.com/jaywcjlove/loading-cli/actions/workflows/ci.yml/badge.svg)](https://github.com/jaywcjlove/loading-cli/actions/workflows/ci.yml)

Terminal loading effect.

# Install

```bash
$ npm install --save loading-cli
```

# Usage

```js
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](https://github.com/jaywcjlove/colors-cli)

```js
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

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

### text

Type: string
Text to display after the spinner.

```js
loading("loading text!!")
```

## color

Values:`black` `red` `green` `yellow` `blue` `magenta` `cyan` `white` `gray`

## frames

```bash
["◰", "◳", "◲", "◱"]
["◐", "◓", "◑", "◒"]
[".", "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.

```js
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](https://github.com/jaywcjlove/github-action-contributors).

## License

Licensed under the MIT License.