cebo
, or c'est beau
in french, is a very simple library that allow to display spinners in terminals.
This is a Node.js module available through the npm registry.
Before installing, download and install Node.js v14.X.X or higher.
Installation is done using the npm install command:
npm install cebo
- Simple tasker with fail or success exit
- Simple spinner runner
- can be used with cli-spinners
For a simple spinner :
import { Spinner } from 'cebo'
const spinner = new Spinner('Connecting to database')
setTimeout(() => {
spinner.success('Connected to database')
}, 2000)
For a hole task :
import { Task } from 'cebo'
await new Task('Connecting to database...', async task => {
// Doing stuff here ...
await new Promise(resolve => setTimeout(resolve, 2000))
task.fail('Connected to database')
}).run()
await new Task('Creating http server...', async task => {
// Doing stuff here ...
await new Promise(resolve => setTimeout(resolve, 3000))
task.success('HTTP server listening on port 8000')
}).run()
Promise, all stuff is very simple and quick.
Create a new spinner. Options can be a string that will be used as spinner text.
Also options can be an object as (here with default values):
new Spinner({
text: '',
color: 'yellow',
spinner: {
interval: 100,
frames: ['◜', '◠', '◝', '◞', '◡', '◟'],
},
autoStart: true,
successChar: '✔',
successCharColor: 'green',
failChar: '✖',
failCharColor: 'red',
})
Start the spinner, already started by default.
Pause the spinner.
Stop and mark as fail the spinner.
Stop and mark as success the spinner.
text
parameter is the pending spinner text.
callback
receive task instance as parameter, can be asynchronous.
spinner
is optionnal, provide a custom spinner.
This method is an async because of async callbacks.
This package follow the following rule :
If it is useless, so it is necessary.
That's all, have a good day =D
Please check the MIT License