https://github.com/molnarmark/spinny
🌀 Spinny is a tiny terminal spinner package for the Nim Programming Language.
https://github.com/molnarmark/spinny
nim nim-lang spinner terminal
Last synced: 2 months ago
JSON representation
🌀 Spinny is a tiny terminal spinner package for the Nim Programming Language.
- Host: GitHub
- URL: https://github.com/molnarmark/spinny
- Owner: molnarmark
- License: mit
- Created: 2017-07-02T22:29:49.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2020-05-28T11:31:27.000Z (almost 5 years ago)
- Last Synced: 2025-03-06T04:56:36.237Z (2 months ago)
- Topics: nim, nim-lang, spinner, terminal
- Language: Nim
- Homepage:
- Size: 942 KB
- Stars: 46
- Watchers: 4
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Spinny
============[](http://badge.fury.io/gh/boennemann%2Fbadges)
[]()Spinny is a tiny terminal spinner package for [Nim Programming Language](https://nim-lang.org).
## Getting Started
You can use Nimble to install the package by running:
```
nimble install spinny
```This library uses threads for spinners, so you have to compile your application
(or add to your ``nim.cfg``):
```
--threads:on
```## Usage
Spinny is quite easy to use. You can set the color, text or symbol of an already running spinner.
```nim
import spinny, osvar spinner1 = newSpinny("Loading file..".fgWhite, Dots)
spinner1.setSymbolColor(fgBlue)
spinner1.start()# do some work here
for x in countup(5, 10):
sleep(500)spinner1.success("File was loaded successfully.")
var spinner2 = newSpinny("Downloading files..".fgBlue, Dots5)
spinner2.setSymbolColor(fgLightBlue)
spinner2.start()# do some work here
for x in countup(5, 10):
sleep(500)spinner2.error("Sorry, something went wrong during downloading!")
```You can even use custom spinners if predefined ones aren't suitable for your needs.
```nim
import spinny, os# makeSpinner accepts two arguments - the interval between different frames,
# and frames themselves (as a sequence of strings)
var spinner3 = newSpinny("I'm custom.", makeSpinner(100, @["x", "y"]))
spinner3.setSymbolColor(fgGreen)
spinner3.start()# do some magnificent work here
for x in countup(1, 5):
sleep(500)spinner3.success("Looks like it's working!")
```Spinny embeds the [colorize](http://github.com/molnarmark/colorize) library for terminal colors.
For spinners to use, take a look at the ``src/spinners.nim`` file. (Credit goes to [sindresorhus](https://github.com/sindresorhus/cli-spinners))## API Reference
The following procs are available on a `Spinny` object:
* `setSymbolColor*(spinny: Spinny, color: proc(x: string): string)`
* `setSymbol*(spinny: Spinny, symbol: string)`
* `setText*(spinny: Spinny, text: string)`
* `start*(spinny: Spinny)`
* `stop*(spinny: Spinny)`
* `success*(spinny: Spinny, msg: string)`
* `error*(spinny: Spinny, msg: string)`## Contributing
All contributions are welcome. Feel free to make this project better. :)
## Authors
* Mark Molnar
## License
* MIT