rattles-terminal-spinners
Minimal terminal spinner library for Rust with preset collection and no-std support
What this skill does
# Rattles Terminal Spinners
> Skill by [ara.so](https://ara.so) — Daily 2026 Skills collection.
**Rattles** is a minimal, zero-dependency Rust library for terminal spinners. It has no runtime or lifecycle — spinners are constructed directly in render loops with negligible cost. Supports `no_std` environments.
## Installation
```toml
# Cargo.toml
[dependencies]
rattles = "0.1" # with std (default)
# no_std
rattles = { version = "0.1", default-features = false }
```
Or via CLI:
```sh
cargo add rattles
# no_std variant
cargo add rattles --no-default-features
```
## Core Concepts
- **Rattler**: a spinner definition (frames + interval). Stateless and cheap to construct.
- **TickedRattler**: stateful wrapper for tick-based driving (required in `no_std`).
- **Presets**: built-in spinners organized by category.
- **`rattle!` macro**: define custom spinners at compile time.
## Basic Usage (std)
```rust
use std::{io::Write, time::Duration};
use rattles::presets::prelude as presets;
fn main() {
let rattle = presets::dots();
loop {
print!("\r{}", rattle.current_frame());
std::io::stdout().flush().unwrap();
std::thread::sleep(Duration::from_millis(80));
}
}
```
`current_frame()` uses the system clock internally — no state needed.
## Preset Categories
```rust
use rattles::presets::{arrows, ascii, braille, emoji};
use rattles::presets::prelude as presets; // re-exports all presets
// Arrows
let s = arrows::arrow();
let s = arrows::arrow2();
// ASCII
let s = ascii::line();
let s = ascii::pipe();
// Braille
let s = braille::dots();
let s = braille::dots2();
// Emoji
let s = emoji::earth();
let s = emoji::clock();
// Prelude examples
let s = presets::waverows();
let s = presets::dots();
```
## Rattler API
```rust
use rattles::presets::prelude as presets;
use std::time::Duration;
let rattle = presets::dots();
// Get frame based on system clock (std only)
let frame: &str = rattle.current_frame();
// Get frame at specific elapsed duration (std + no_std)
let frame = rattle.frame_at(Duration::from_millis(500));
// Get frame by index
let frame = rattle.frame(3);
// Change animation interval
let rattle = presets::dots().set_interval(Duration::from_millis(50));
// Reverse direction
let rattle = presets::waverows().reverse();
// Convert to tick-based (stateful)
let mut ticked = presets::dots().into_ticked();
```
## TickedRattler (Stateful / no_std-friendly)
```rust
use rattles::presets::prelude as presets;
let mut rattle = presets::dots().into_ticked();
loop {
rattle.tick();
let frame = rattle.current_frame();
// render frame...
}
```
`TickedRattler` must be stored (it holds state). Suitable for `no_std` contexts where the global clock is unavailable.
## Index-Based Animation (no_std)
```rust
use rattles::presets::prelude as presets;
let rattle = presets::dots();
let mut i = 0usize;
loop {
let frame = rattle.frame(i);
i = i.wrapping_add(1);
// render frame...
}
```
## Time-Based Animation with External Clock (no_std)
```rust
use rattles::presets::prelude as presets;
use core::time::Duration;
let rattle = presets::dots();
// elapsed comes from your platform's timer
let elapsed: Duration = get_elapsed(); // your implementation
let frame = rattle.frame_at(elapsed);
```
## Custom Spinners with `rattle!` Macro
```rust
use rattles::rattle;
rattle!(
MySpinner, // generated struct name
my_spinner, // generated constructor function name
1, // row count (width of spinner)
120, // interval in milliseconds
["⣾", "⣷", "⣯", "⣟", "⣻", "⣽"] // keyframes
);
// Use it like any preset
let s = my_spinner();
println!("{}", s.current_frame());
```
Multi-row custom spinner:
```rust
rattle!(
Wide,
wide_spinner,
3, // 3 characters wide
80,
["[ ]", "[= ]", "[== ]", "[===]", "[ ==]", "[ =]"]
);
```
## Ratatui Integration
```rust
// examples/ratatui.rs pattern
use rattles::presets::prelude as presets;
use ratatui::{
backend::CrosstermBackend,
widgets::Paragraph,
Terminal,
};
fn ui(frame: &mut ratatui::Frame, rattle: &rattles::Rattler) {
let spinner_text = rattle.current_frame();
let paragraph = Paragraph::new(format!("{} Loading...", spinner_text));
frame.render_widget(paragraph, frame.size());
}
fn main() -> std::io::Result<()> {
let rattle = presets::dots();
// standard ratatui event loop
loop {
terminal.draw(|f| ui(f, &rattle))?;
std::thread::sleep(std::time::Duration::from_millis(16));
// break on user input...
}
Ok(())
}
```
Since `Rattler` is stateless, pass it by reference anywhere — no `Arc<Mutex<>>` needed.
## no_std Setup
```toml
[dependencies]
rattles = { version = "0.1", default-features = false }
```
```rust
#![no_std]
use rattles::presets::prelude as presets;
// Option 1: tick-based
let mut rattle = presets::dots().into_ticked();
rattle.tick();
let frame = rattle.current_frame();
// Option 2: index-based
let rattle = presets::dots();
let frame = rattle.frame(42);
// Option 3: duration-based (external clock)
let rattle = presets::dots();
let frame = rattle.frame_at(core::time::Duration::from_millis(840));
```
## Common Patterns
### Spinner with message
```rust
use rattles::presets::prelude as presets;
use std::{io::Write, time::Duration};
fn main() {
let rattle = presets::dots();
let message = "Fetching data...";
loop {
print!("\r{} {}", rattle.current_frame(), message);
std::io::stdout().flush().unwrap();
std::thread::sleep(Duration::from_millis(80));
}
}
```
### Async-compatible (tokio)
```rust
use rattles::presets::prelude as presets;
use tokio::time::{sleep, Duration};
#[tokio::main]
async fn main() {
let rattle = presets::dots();
let spinner = tokio::spawn(async move {
loop {
print!("\r{}", rattle.current_frame());
std::io::stdout().flush().unwrap();
sleep(Duration::from_millis(80)).await;
}
});
// do your async work
do_work().await;
spinner.abort();
println!("\rDone! ");
}
```
### Collecting all frames
```rust
let rattle = presets::dots();
let frames: Vec<&str> = (0..rattle.frame_count())
.map(|i| rattle.frame(i))
.collect();
```
## Troubleshooting
**Spinner not animating (stuck on first frame)**
- Ensure you're flushing stdout: `std::io::stdout().flush().unwrap()`
- Use `\r` to overwrite the line, not `\n`
- The sleep interval should match or be shorter than the spinner's interval
**`current_frame()` not available in no_std**
- Use `frame_at(duration)`, `frame(index)`, or `into_ticked()` instead
- Disable default features: `rattles = { version = "...", default-features = false }`
**Custom spinner not compiling**
- Keyframes must be string literals in the `rattle!` macro array
- Row count must match the visual width of each keyframe string
**Spinner looks garbled in terminal**
- Some braille/emoji frames require a terminal with Unicode support
- Test with ASCII presets (`ascii::line()`) to verify basic functionality first
Related in Backend & APIs
jfrog
IncludedInteract with the JFrog Platform via the JFrog CLI and REST/GraphQL APIs. Use this skill when the user wants to manage Artifactory repositories, upload or download artifacts, manage builds, configure permissions, manage users and groups, work with access tokens, configure JFrog CLI servers, search artifacts, manage properties, set up replication, manage JFrog Projects, run security audits or scans, look up CVE details, query exposures scan results from JFrog Advanced Security, manage release bundles and lifecycle operations, aggregate or export platform data, or perform any JFrog Platform administration task. Also use when the user mentions jf, jfrog, artifactory, xray, distribution, evidence, apptrust, onemodel, graphql, workers, mission control, curation, advanced security, exposures, or any JFrog product name.
cupynumeric-migration-readiness
IncludedPre-migration readiness assessor for porting NumPy to cuPyNumeric. Use BEFORE substantial porting work begins when the user asks whether code will scale on GPU, whether they should migrate to cuPyNumeric, which NumPy patterns transfer cleanly, what must be refactored before porting, or mentions pre-port assessment, scaling analysis, or refactor planning. Inspect the user's source code, look up NumPy usage, cross-reference the cuPyNumeric API support manifest, and distinguish distributed-scaling-friendly patterns from blockers such as unsupported APIs, scalar synchronization, host round-trips, Python/object-heavy control flow, shape/data-dependent branching, and in-place mutation hazards. Produce a verdict of READY, LIGHT REFACTOR, SIGNIFICANT REFACTOR, or NOT RECOMMENDED, with concrete refactor pointers.
alibabacloud-data-agent-skill
IncludedInvoke Alibaba Cloud Apsara Data Agent for Analytics via CLI to perform natural language-driven data analysis on enterprise databases. Data Agent for Analytics is an intelligent data analysis agent developed by Alibaba Cloud Database team for enterprise users. It automatically completes requirement analysis, data understanding, analysis insights, and report generation based on natural language descriptions. This tool supports: discovering data resources (instances/databases/tables) managed in DMS, initiating query or deep analysis sessions, real-time progress tracking, and retrieving analysis conclusions and generated reports. Use this Skill when users need to query databases, analyze data trends, generate data reports, ask questions in natural language, or mention "Data Agent", "data analysis", "database query", "SQL analysis", "data insights".
token-optimizer
IncludedReduce OpenClaw token usage and API costs through smart model routing, heartbeat optimization, budget tracking, and native 2026.2.15 features (session pruning, bootstrap size limits, cache TTL alignment). Use when token costs are high, API rate limits are being hit, or hosting multiple agents at scale. The 4 executable scripts (context_optimizer, model_router, heartbeat_optimizer, token_tracker) are local-only — no network requests, no subprocess calls, no system modifications. Reference files (PROVIDERS.md, config-patches.json) document optional multi-provider strategies that require external API keys and network access if you choose to use them. See SECURITY.md for full breakdown.
resend-cli
IncludedUse this skill when the task is specifically about operating Resend from an AI agent, terminal session, or CI job via the official resend CLI: installing/authenticating the CLI, sending/listing/updating/cancelling emails, batch sends, domains and DNS, webhooks and local listeners, inbound receiving, contacts, topics, segments, broadcasts, templates, API keys, profiles, or debugging Resend CLI/API failures. Trigger on mentions of Resend CLI, `resend`, `resend doctor`, `resend emails send`, `resend domains`, `resend webhooks listen`, `resend emails receiving`, or agent-friendly terminal automation.
alibabacloud-odps-maxframe-coding
IncludedUse this skill for MaxFrame SDK development and documentation navigation on Alibaba Cloud MaxCompute (ODPS). Helps answer MaxFrame API, concept, official example, and supported pandas API questions; create data processing programs; read/write MaxCompute tables; debug jobs (remote or local); and build custom DPE runtime images. Trigger when users mention MaxFrame, MaxCompute with MaxFrame, ODPS table processing, DPE runtime, MaxFrame docs/examples, DataFrame/Tensor operations, or GPU runtime setup. Works for both English and Chinese queries about Alibaba Cloud data processing with MaxFrame.