jbcarpanelli / spinnies

Node.js module to create and manage multiple spinners in command-line interface programs
MIT License
150 stars 34 forks source link

Lots of features #17

Open SweetMNM opened 5 years ago

SweetMNM commented 5 years ago

Now i know PRs usually tackle a single bug/feature but i had some ideas for this library that i thought might be useful.

I created tests and documented in the README every new feature added.

I suggest you read the README first. Then you might want to go commit by commit to review? i don't know. Also if you do make sure you read the description for the commits. Sorry if this is a lot.

Features added (in general): Remove a spinner using spinnies.remove() - this was before you implemented it

The spinner animation can be changed while spinning using spinnies.setFrames();

Optionally use spinners from the cli-spinners library (it's an optional dependency)

wordwrapjs is used to break text, that way words don't get broken in the middle.

In multiline spinners each line after the first line will be indented to the prefix (see demo).

Add support for the indent option - this was before #15 was implemented... Every line in a multiline spinner will be indented by this option.

Each spinner will now have it's own instance. Spinner's can be updated from the main instance and directly from that spinner.

Statuses can be set using spinnies.status();

signal-exit library is used to bind exit event instead of just binding the 'sigint' event. Also that listener will be unbound whenever spinnies is done spinning.

os.EOL is used instead of just assuming '\n'.

A regex to match '\n', '\r' and '\r\n' is used instead of just looking for '\n'.

A different util called purgeOptions under purgeOptions.js will be used to purge any kind of options. This is more of the behind the scenes since it shouldn't effect the actual way the library works but just make it easier to purge preference.

Implement custom statuses.

Improve CI (raw) rendering instead of printing out all of the spinners only the updated spinner will be printed.

Create warn and info status (super easy with custom statuses).

Add the ability to hide spinners and show them later.

Update the demo and the demo gif.

Create spinnies.text() to only modify the text.

Create spinnies.indent() to only modify the indent.

Improve CI detection by checking for more ENV variables that are used by CI services.

Add table of contents to the README.

Add 'Features' section to the README.

Also i have an idea for a 'bind' method. Something like what you suggested in #3. You can pass it a promise, if the promise rejects it will fail the spinner, if the promise resolved it will succeed the spinner. You can also pass it an observable, next() will update the spinner's text, complete() will succeed it and error() will fail it. Similar to how listr works.

Thank you so much for creating this amazing library. I hope you find the time to review this PR and hopefully merge.