Term::Spinner - Arguably the best way to create spinners for CLIs

So I just finished work on another addition to my crystal-term project. This one, Term::Spinner is a fully featured async spinner library for Crystal CLI applications. It allows you to create a spinner which can be used to track the progress of a task, updated to show different statuses, and indicate error or success once the task is complete. For example:

asciicast

You can also use Term::Spinner::Multi to create a multispinner, which can contain any number of other individual spinners, each with their own jobs:

asciicast

It’s been hard work getting to this point, a lot more than I thought for just making spinners in a terminal, but it should be ready to use. Let me know if you have any thoughts!

9 Likes

Pretty nice!

The only thing that bugs me is that your Term::Cursor hardcodes the terminal control sequences, which might not work with all terminals.
The proper way to fix this would be to use the terminfo database of the current terminal, but this is more hard work^^
I actually have a work in progress lib to parse those terminfo databases, I’ll try to work again on the missing pieces (the expansion part, the specs, some doc)

Yeah parsing terminfo would be a lot better, although I do have most cases covered so they should work on most terminals. At least ones that have successfully implemented the VT100 escape sequences.

Hi! I love the project, I’m loving elixir and I like working with CLI apps in general.

I would love to help. Do you have any plans or ideas that are suitable for collaboration?

Nothing currently. I mean all of my projects are open to improvement, especially those in the crystal-term namespace like this project. The code is all new, definitely full of bugs, and could use some refactoring and specs.

1 Like

Very cool project! Are you trying to build a cli framework? I’d like to contribute in by spare time.
Have you considered the idea of making one single shard shipping all the libraries in one? This would be useful for including all the namespace with a single import.

If shards would support monolibraries I would, but as it is I prefer having things separated into their own libraries. Unfortunately ysbaddadan has been historically opposed to supporting monolibraries in Crystal, so I don’t see that happening.

I am attempting to write a CLI which I plan to use this with, but not a framework. We have plenty of those.

1 Like