strides 0.4.0

Async-first terminal UI spinners and progress bars
Documentation

strides

Cargo Documentation

A command-line UI library to enhance async programs with progress bars and spinners. It is async-first, opinionated, far from feature complete and absolutely not API stable. Use at your own risk.

The crate is built around two extension traits and one container:

  • future::FutureExt adds .progress(theme) to any Future, returning a builder that composes optional capabilities — with_message, with_messages and with_fraction.
  • stream::StreamExt adds .progress(theme, fraction_fn) to any Stream, returning a builder with with_messages.
  • future::Group runs many futures concurrently and renders one line per task. Bare futures convert into future::Task implicitly; configure with with_label, with_messages and with_progress (mirrored on FutureExt).

A Theme bundles a spinner::Spinner and a bar::Bar and is accepted everywhere a theme is expected; bare spinners convert implicitly. See spinner::styles and bar::styles for predefined variants.

use futures_lite::StreamExt as _;
use strides::stream::StreamExt;

Example

Three concurrently running futures with a customized spinner and elapsed time:

use std::time::Duration;
use async_io::Timer;
use futures_lite::{StreamExt, future};
use strides::future::{FutureExt, Group};
use strides::spinner;

let mut group = Group::new(spinner::styles::DOTS_3)
    .with_spinner_style(owo_colors::Style::new().bright_purple().bold())
    .with_elapsed_time(true);

group.push(Timer::after(Duration::from_secs(1)).with_label("one second"));
group.push(Timer::after(Duration::from_secs(2)).with_label("two seconds"));
group.push(Timer::after(Duration::from_secs(3)).with_label("three seconds"));

future::block_on(async {
    group.for_each(|_| {}).await;
});

See the examples directory for more elaborate uses including downloads, dynamic messages, and per-task progress bars.

License

MIT