百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
S

spinoff

> 开发工具
开源

易于使用、强大的 Rust 库,可在终端中显示旋转器

577 stars0 点赞2 次浏览
访问官网GitHub

工具介绍

易于使用、强大的 Rust 库,可在终端中显示旋转器

spinoff

an easy to use, robust library for displaying spinners in the terminal

Install

Add as a dependency to your Cargo.toml:

toml
[dependencies]
spinoff = "0.8.0"
```	

## ⚡ Usage

```rust
use spinoff::{Spinner, spinners, Color};
use std::thread::sleep;
use std::time::Duration;

let mut spinner = Spinner::new(spinners::Dots, "Loading...", Color::Blue); 
sleep(Duration::from_secs(3));
spinner.success("Done!");

Update a spinner

rust
use spinoff::{Spinner, spinners, Color};
use std::thread::sleep;
use std::time::Duration;

let mut spinner = Spinner::new(spinners::Aesthetic, "Loading...", Color::Red); 
sleep(Duration::from_secs(3));
spinner.update(spinners::Dots2, "Retrying...", None);
sleep(Duration::from_secs(3));
spinner.stop()

Specify an output stream

rust
use spinoff::{Spinner, spinners, Color, Streams};
use std::thread::sleep;
use std::time::Duration;

let mut spinner = Spinner::new_with_stream(spinners::Line, "Loading...", Color::Yellow, Streams::Stderr);
sleep(Duration::from_secs(3));
spinner.stop_and_persist("", "Task done.");

Spinners

spinoff includes over 80+ spinner variants out of the box. All spinner variants are treated as features that can be enabled or disabled. By default, all of them are enabled for ease of use. To disable/enable variants, you will have to edit your cargo.toml file:

toml
[dependencies]
spinoff = { version = "0.8.0", features = ["dots", "arc", "line"] }

Any suggestions for new spinner variants are welcome.

Creating your own spinner

You can create your own spinner using the spinner! macro:

rust
use spinoff::*;
use std::thread::sleep;
use std::time::Duration;

let frames = spinner!([">", ">>", ">>>"], 100);
let mut sp = Spinner::new(frames, "Hello World!", None);
sleep(Duration::from_millis(800));
sp.stop();

Multiline messages

spinoff doesn't support spinners with multiline text out of the box. If you want to use it in your project, please look at #27.

❗Note for Windows Users

For colors to work properly, you need to add a few extra lines to your code:

rust
use colored::control
control::set_virtual_terminal(true).unwrap();

Documentation

  • All relevant documentation can be found on the Docs.rs page.
  • If you want to see all the available spinner options, refer to the spinner module.

⚙ Examples

bash
cargo run --example simple
bash
cargo run --example stream
bash
cargo run --example stop_and_persist

Other examples can be found in the documentation.

Contributing

Any contributions to this crate are highly appreciated. If you have any ideas/suggestions/bug fixes, please open an issue or a pull request. If you like the project, star this project on GitHub.

License

This crate is licensed under the MIT license.

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

Rustclicommand-linecommand-line-toolspinner

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月17日
分类开发工具
定价开源

> 相关工具

V
VS Code
流行的开源代码编辑器
G
Git
分布式版本控制系统
V
Vite
下一代前端构建工具