https://github.com/comandeer/cli-spinner
Simple CLI spinner
https://github.com/comandeer/cli-spinner
Last synced: 3 months ago
JSON representation
Simple CLI spinner
- Host: GitHub
- URL: https://github.com/comandeer/cli-spinner
- Owner: Comandeer
- License: mit
- Created: 2021-07-31T17:34:06.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2023-08-02T18:16:18.000Z (almost 2 years ago)
- Last Synced: 2025-02-03T16:52:28.205Z (4 months ago)
- Language: TypeScript
- Size: 993 KB
- Stars: 2
- Watchers: 3
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
# @comandeer/cli-spinner
[](https://github.com/Comandeer/cli-spinner/actions) [](https://codecov.io/gh/Comandeer/cli-spinner) [](https://npmjs.com/package/@comandeer/cli-spinner)
Super simple CLI spinner.
## Installation
```bash
npm install @comandeer/cli-spinner --save
```## Usage
```javascript
import Spinner from '@comandeer/cli-spinner';const spinner = new Spinner( {
label: 'Working…'
} );await spinner.show();
//do something
await spinner.hide();
```## Configuration
You can configure the spinner by passing options via `options` object in the constructor:
```javascript
const spinner = new Spinner( options );
```The list of available options is presented below:
| Name | Type | Default value | Description |
| ---------- | ----------------------------------------------------- | ------------------------------------------------------------ | ------------------------------------------------------------ |
| `stdout` | [`Stream`](https://nodejs.org/api/stream.html#stream) | [`process.stderr`](https://nodejs.org/api/process.html#processstderr) | Stream to which the spinner will be outputted. |
| `label` | `string` | `''` | Additional text label that will be displayed next to the spinner. |
| `spinner` | `Array` | See [`src/defaultSpinner.js`](https://github.com/Comandeer/cli-spinner/blob/main/src/defaultSpinner.js) | An array containing frames that will be used to animate the spinner. |
| `interval` | `number` | 80 | Indicates how often frames of the spinner should be changed. |## Why should I use it instead of x?
The truth is: you probably shouldn't. This package was created because I couldn't stand the API of [`gauge`](https://github.com/npm/gauge) and [`ora`](https://github.com/sindresorhus/ora) didn't work for me for some reason. As I have quite severe [NIH syndrome](https://en.wikipedia.org/wiki/Not_invented_here), I decided to create my own, very naive implementation of a CLI spinner.
So if you look for a battle-tested solution and don't mind more convoluted API, use `gauge`. If you prefer a battle-tested solution but with really user-friendly API, use `ora`. If for some reason these solutions don't work for you, you probably still shouldn't use this package.
## License
See [LICENSE](./LICENSE) file for details.