https://github.com/couapy/cebo
cebo, or c'est beau in french, is a very simple library that allow to display spinners in terminals.
https://github.com/couapy/cebo
Last synced: about 2 months ago
JSON representation
cebo, or c'est beau in french, is a very simple library that allow to display spinners in terminals.
- Host: GitHub
- URL: https://github.com/couapy/cebo
- Owner: Couapy
- License: mit
- Created: 2021-08-02T17:29:29.000Z (almost 5 years ago)
- Default Branch: main
- Last Pushed: 2021-08-02T17:54:26.000Z (almost 5 years ago)
- Last Synced: 2025-03-08T06:17:00.828Z (about 1 year ago)
- Language: JavaScript
- Homepage:
- Size: 10.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# cebo
`cebo`, or `c'est beau` in french, is a very simple library that allow to display spinners in terminals.
## Installation
This is a [Node.js](https://nodejs.org/en/) module available through the [npm registry](https://www.npmjs.com/).
Before installing, [download and install Node.js](https://nodejs.org/en/download/) v14.X.X or higher.
Installation is done using the [npm install command](https://docs.npmjs.com/downloading-and-installing-packages-locally):
```bash
npm install cebo
```
## Features
- Simple tasker with fail or success exit
- Simple spinner runner
- can be used with [cli-spinners](https://www.npmjs.com/package/cli-spinners)
## Quick start
For a simple spinner :
```javascript
import { Spinner } from 'cebo'
const spinner = new Spinner('Connecting to database')
setTimeout(() => {
spinner.success('Connected to database')
}, 2000)
```
For a hole task :
```javascript
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()
```
## Documentation
Promise, all stuff is very simple and quick.
### Spinner
#### Spinner(options)
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):
```javascript
new Spinner({
text: '',
color: 'yellow',
spinner: {
interval: 100,
frames: ['◜', '◠', '◝', '◞', '◡', '◟'],
},
autoStart: true,
successChar: '✔',
successCharColor: 'green',
failChar: '✖',
failCharColor: 'red',
})
```
#### Spinner.start()
Start the spinner, already started by default.
#### Spinner.stop()
Pause the spinner.
#### Spinner.fail(text)
Stop and mark as fail the spinner.
#### Spinner.success(text)
Stop and mark as success the spinner.
### Task
#### Task(text, callback, ?spinner)
`text` parameter is the pending spinner text.
`callback` receive task instance as parameter, can be asynchronous.
`spinner` is optionnal, provide a custom spinner.
#### Task.run()
This method is an async because of async callbacks.
## Pilosophy
This package follow the following rule :
```text
If it is useless, so it is necessary.
```
That's all, have a good day =D
## License
Please check the [MIT License](./LICENSE)