Today I'd like to share a tiny tool called nanospinner. It does one thing and one thing only: it shows a terminal spinner and a ✔ when complete!
As usual, install with deno add npm:nanospinner
and create a file, e.g. main.ts
with the following contents:
import { createSpinner } from 'nanospinner'
const spinner = createSpinner('Counting days till Christmas').start()
setTimeout(() => {
spinner.success()
}, 2000)
Start with e.g. deno run -A ./main.ts
and behold:
In addition to spinner.success
there's expectably spinner.warn
and spinner.error
.
All of those methods can be customised in a multitude of ways: from colors and symbols to custom animation frames!
Check it out and share you creations!
Liked the content and would love to have more of it all year long?
Interesting thing is that such stuff doesn’t necessarily work as it is for all the environments. I saw that for instance spinners and similar animated stuff looks differently if the resulting CLI app is dockerized (with barebones primitive images) or run from similar minimalist environments — they are replaced with something like [loading started] or [loading ended] — which doesn’t look that fancy at all. So one should be aware of such things if they build CLIs for versatile environments and provide for some kind of graceful degradation. Because [loading started] may look ugly in the context of some ambitious CLI project 😅