jbcarpanelli / spinnies Goto Github PK
View Code? Open in Web Editor NEWNode.js module to create and manage multiple spinners in command-line interface programs
License: MIT License
Node.js module to create and manage multiple spinners in command-line interface programs
License: MIT License
I'm using spinnies to display the status of various stack deployments in makeshift/terragrunt-status, and it's working pretty great.
However, due to the binary nature of success/failure, it's sometimes hard to convey at a glance the status of a command that's been ran. Currently I'm using 'failed' as 'the whole command failed' and success for everything else. For anything in-between I have the text become yellow, but the successPrefix is still a green tick as it's defined when the spinny is created and can't (currently) be updated later.
I'd like to be able to update the successPrefix
later in the spinnies lifecycle, so I can emulate statuses that are neither success nor failure by simply having a different prefix + text colour.
Hi, what is awesome about this spinner, is that it updates the spinner at the same location in terminal it started. but sometimes after the spinner starts I want to log some text while the task is processing, this means if there is a lot of text output, the user will have to scroll back to the spinner start position in terminal to check if it succeeded or failed.
so could we have an option in this case, where we start the spinner, then at some point in future when we decide to do an update with success or fail, we can spit that to the terminal at the desired location?
hope i made it clear enough, thanks in advance.
Hi,
it would be great to have info
and warn
api methods like Ora spinner.
thanks in advance.
Hi,
really awesome spinner and options, thanks alot for it :)
but can you please disable the enforcement of dashes spinners on win32, i am using windows 10 and it is perfectly capable of showing all symbols, i tested by manually commenting the if condition and it wokred.
thanks in advace :)
I got strange dublication in the CLI log and locally with disableSpins
option:
- Downloading https://github.com/logux/logux/archive/master.zip
- Downloading https://github.com/logux/logux/archive/master.zip
- Downloading https://github.com/logux/core/archive/master.zip
- Downloading https://github.com/logux/logux/archive/master.zip
- Downloading https://github.com/logux/core/archive/master.zip
- Downloading https://github.com/logux/server/archive/master.zip
- logux downloaded
- Downloading https://github.com/logux/core/archive/master.zip
- Downloading https://github.com/logux/server/archive/master.zip
- logux downloaded
- logux-core downloaded
- Downloading https://github.com/logux/server/archive/master.zip
- logux downloaded
- logux-core downloaded
- logux-server downloaded
- logux downloaded
- logux-core downloaded
- logux-server downloaded
- Converting guides
- logux downloaded
- logux-core downloaded
- logux-server downloaded
- Converting guides
- Generating JSDoc
- logux downloaded
- logux-core downloaded
- logux-server downloaded
- Guide converted
- Generating JSDoc
- logux downloaded
- logux-core downloaded
- logux-server downloaded
- Guide converted
- JSDoc generated
- logux downloaded
- logux-core downloaded
- logux-server downloaded
- Guide converted
- JSDoc generated
- Building guides HTML
- logux downloaded
- logux-core downloaded
- logux-server downloaded
- Guide converted
- JSDoc generated
- Building guides HTML
- Building API HTML
- logux downloaded
- logux-core downloaded
- logux-server downloaded
- Guide converted
- JSDoc generated
- Building guides HTML
- API HTML generated
- logux downloaded
- logux-core downloaded
- logux-server downloaded
- Guide converted
- JSDoc generated
- Guides HTML generated
- API HTML generated
But with spinners (locally without disableSpins
) everything works good.
I strarted this spinners only (pseudocode):
await Promise.all(projects.map(async ([url, name]) => {
spin.add(`download-${ name }`, { text: `Downloading ${ url }` })
await donwload(name, url)
spin.succeed(`download-${ name }`, { text: `${ name } downloaded` })
})
Promise.all([
async () => {
spin.add('process-guides', { text: 'Converting guides' })
await process()
spin.succeed('process-guides', { text: 'Guide converted' })
}),
async () => {
spin.add(`jsdoc${ projects.join() }`, { text: 'Generating JSDoc' })
await jsdoc()
spin.succeed(`jsdoc${ projects.join() }`, { text: 'JSDoc generated' })
})
])
Promise.all([
async () => {
spin.add('build-api', { text: 'Building API HTML' })
await buildHTML('guide')
spin.succeed('build-api', { text: 'API HTML generated' })
}),
async () => {
spin.add('build-pages', { text: 'Building guides HTML' })
await buildHTML('api')
spin.succeed('build-pages', { text: 'Guides HTML generated' })
})
])
Could be an dublicate for #13
The idea is to implement a new method called remove
that receives a spinner reference name as argument and removes that spinner from the list, and thus should not be printed again in the terminal If no reference is given, the method call does nothing.
Example usage:
const spinnies = new Spinnies();
spinnies.add('spinner-1');
spinnies.add('spinner-2');
spinnies.add('spinner-3');
setTimeout(() => {
spinnies.remove('spinner-2');
}, 3000); // => should remove the second spinner and not print it again.
Instead of setting a spinner as succeed/fail using the spinners#fail
and spinner#succeed
methods, it would be great if spinnies
could do this automatically when sending a promise as an option:
spinnies.add('spinner-1', {
text: 'Doing X..',
onPromise: {
promise: someFunction(arg1, arg2),
succeed: {
text: 'X succeeded',
color: 'greenBright'
},
fail: {
...
}
});
hi,
it would be great if we have typings so we get IntelliSense in IDE and stop typescript complaining.
const Spinnies = require('spinnies');
const spinnies = new Spinnies();
spinnies.add('foo');
setTimeout(() => spinnies.succeed('foo'), 5000);
process.on('SIGINT', () => {
process.stdout.write('^C received\n');
process.exit(0);
});
The custom callback function is never launched.
Thank you for maintaining this lib! ora
has an indent
property, could this be implemented here ?
The code below should exit cleanly after the timeout callback is fired.
const Spinnies = require("spinnies");
const spinners = new Spinnies();
spinners.add("spinner-1", { text: "some spinner" });
setTimeout(() => {
spinners.remove("spinner-1");
console.log("I should exit now!");
},1000);
The spinner is removed as expected, but the node
process hangs after printing the text I should exit now
.
The following code exits as expected (note the addition of spinners.checkIfActiveSpinners()
after the call to spinners.remove
:
const Spinnies = require("spinnies");
const spinners = new Spinnies();
spinners.add("spinner-1", { text: "some spinner" });
setTimeout(() => {
spinners.remove("spinner-1");
spinners.checkIfActiveSpinners();
console.log("I should exit now!");
},1000);
I think the fix proposed in SweetMNM#1 (a PR to a fork of this project) would also work here, though the patch itself likely wouldn't apply cleanly.
This should include a nonSpinnablePrefix
prefix, a successPrefix
and a failPrefix
, that should override the defaults. If any of these attributes are deliberately set to 'null', non prefix should be shown.
I recently saw on bundlephobia that the package kleur is way smaller than chalk and has a similiar syntax. Kleur is also dependency free. What are your thoughts about replacing it with chalk to reduce the bundle size?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.