Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ashlinharris/spinners.jl
Command line spinners in Julia with Unicode support
https://github.com/ashlinharris/spinners.jl
command-line julia linux macos spinner spinners terminal unicode windows
Last synced: about 1 month ago
JSON representation
Command line spinners in Julia with Unicode support
- Host: GitHub
- URL: https://github.com/ashlinharris/spinners.jl
- Owner: AshlinHarris
- License: mit
- Created: 2022-08-19T15:51:24.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-09-15T18:44:51.000Z (over 1 year ago)
- Last Synced: 2024-08-09T07:51:26.667Z (5 months ago)
- Topics: command-line, julia, linux, macos, spinner, spinners, terminal, unicode, windows
- Language: Julia
- Homepage:
- Size: 276 KB
- Stars: 13
- Watchers: 2
- Forks: 1
- Open Issues: 7
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Spinners.jl
Command line spinners in Julia with Unicode support
[![Build Status](https://github.com/AshlinHarris/Spinners.jl/actions/workflows/ci.yml/badge.svg)](https://github.com/AshlinHarris/Spinners.jl/actions/workflows/ci.yml) [![Coverage](https://codecov.io/gh/ashlinharris/Spinners.jl/branch/main/graph/badge.svg)](https://codecov.io/gh/AshlinHarris/Spinners.jl)
![spinners](https://user-images.githubusercontent.com/90787010/189241813-9ff87134-7b57-4e53-829b-32c6bc660851.gif)
## Description
`Spinners.jl` provides a single macro (`@spinner`), which generates a command line spinner for a command.
The spinner should draw continuously until the command elapses, and the macro should not affect the scope of the command.
All user input is captured while the spinner is running, but the spinner can be stopped prematurely with `Ctrl-C`, `Ctrl-D`, or `Esc` (the user command will keep going).Command line spinners serve as a visual indicator to the user that a process is ongoing and shouldn't be interrupted (e.g., files are being downloaded or written to disk).
The API for `Spinners.jl` should be considered unstable until v1.0.
## Examples:
```
using Spinners# The @spinner macro shouldn't affect the scope:
do_some_calculations(x) = sum(map(i -> BigInt(999)^10_000_000 % i, 1:x))
@spinner x = do_some_calculations(10);
println(x)# You can provide a character set, but many are already built in:
@spinner "◧◨" 0.5 sleep(5)
@spinner [" 🐈", " 🐈🐾", " 🐈🐾🐾", "🐈🐾🐾🐾"] 0.5 sleep(5)
@spinner :aesthetic
@spinner :shutter
@spinner :pong
@spinner :cards#There is also a random mode:
@spinner :dots :rand
@spinner :clock :rand sleep(4)
```## Related Works
I highly recommend [ProgressMeter.jl](https://github.com/timholy/ProgressMeter.jl), which includes spinners as a flavor of progress meter.
That is, they're useful tools for measuring the progress of a function, and they must be updated at points within the function.
In contrast, `Spinners.jl` is a useless novelty for drawing command line spinners.
The spinner is controlled by an external process and doesn't measure progress, which treats the user function as a black box.
The process receives a signal when the user's function is complete, so the user doesn't need to add breaks to their function.In Julia:
- [timholy/ProgressMeter.jl](https://github.com/timholy/ProgressMeter.jl)
- [FedeClaudi/Term.jl](https://github.com/FedeClaudi/Term.jl)
- https://fedeclaudi.github.io/Term.jl/stable/adv/progressbars/
- JuliaLang/Pkg.jl spinners:
- [MiniProgressBars.jl](https://github.com/JuliaLang/Pkg.jl/blob/master/src/MiniProgressBars.jl)
- [API.jl](https://github.com/JuliaLang/Pkg.jl/blob/master/src/API.jl)
- [cloud-oak/ProgressBars.jl](https://github.com/cloud-oak/ProgressBars.jl)
- [KristofferC/TerminalSpinners.jl](https://github.com/KristofferC/TerminalSpinners.jl)
- [rahulkp220/Spinner.jl (defunct)](https://github.com/rahulkp220/Spinner.jl)
In other languages:
- [sindresorhus/cli-spinners (JavaScript)](https://github.com/sindresorhus/cli-spinners)
- Some assets in Spinners.jl come from here.## Related discussions:
- https://discourse.julialang.org/t/update-stdout-while-a-function-is-running/86285
- https://discourse.julialang.org/t/how-to-print-rotating-tick-as-progress-bar-in-terminal/62099