Giter Site home page Giter Site logo

loading-cli's Introduction

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.

loading-cli's People

Contributors

jaywcjlove avatar renovate[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

loading-cli's Issues

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Other Branches

These updates are pending. To force PRs open, click the checkbox below.

  • chore(deps): update actions/checkout action to v4
  • chore(deps): update actions/setup-node action to v4

Detected dependencies

github-actions
.github/workflows/ci.yml
  • actions/checkout v3
  • actions/setup-node v3
  • peaceiris/actions-gh-pages v3
npm
package.json
  • colors-cli ^1.0.26

  • Check this box to trigger a request for Renovate to run again on this repository

Nothing print on terminal

I have a loop where i do some computation and I set load.text to a new value.
The problem nothing got printed. If I console.log(m) it print m.
But If I add "await new Promise((resolve) => setTimeout(resolve));" then it is print.
Has anyone ever have this error ?
I used this very usefull library in other part of my projects and no need for await.
So this is very strange.

请将开发依赖改成安装依赖

一运行,报了这个错

发生异常: Error
Error: Cannot find module 'colors-cli'

package.json里

"devDependencies": {
    "colors-cli": "^1.0.7"
  }

请改成

"dependencies": {
    "colors-cli": "^1.0.7"
  }

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.