πŸ›Ž 60+ Elegant terminal spinners for Rust

Overview

Spinners - πŸ›Ž 60+ Elegant terminal spinners for Rust

Cargo version Crates.io docs.rs Crates.io Slack

❀️ Shameless plug

Install

See Cargo page

Usage

extern crate spinners;

use spinners::{Spinner, Spinners};
use std::thread::sleep;
use std::time::Duration;

fn main() {
    let sp = Spinner::new(Spinners::Dots9, "Waiting for 3 seconds".into());
    sleep(Duration::from_secs(3));
    sp.stop();
}

Example

cargo run --example cycle
cargo run --example simple

License

MIT © François-Guillaume Ribreau

Comments
  • Potential issue with Rust 2021 edition?

    Potential issue with Rust 2021 edition?

    Hi there,

    I just tried your library on 2021 and it is thowing an error when running the shown example.

    thread '' panicked at 'called Result::unwrap() on an Err value: NotSupported', C:\Users\exfho.cargo\registry\src\github.com-1ecc6299db9ec823\spinner-0.5.0\src\lib.rs:164:37

    I thought I'd let you know.

    question 
    opened by shapedthought 11
  • Examples panic

    Examples panic

    Running with current Rust, this happens

     ❀ (azedes) ~/P/c/spinners> cargo run --example simple
       Compiling spinners v1.0.1-alpha.0 (/home/spacekookie/Personal/clones/spinners)
        Finished dev [unoptimized + debuginfo] target(s) in 0.36s
         Running `target/debug/examples/simple`
    thread '<unnamed>' panicked at 'called `Option::unwrap()` on a `None` value', src/libcore/option.rs:355:21
    note: Run with `RUST_BACKTRACE=1` for a backtrace.
    ^C⏎                                                                                                       (130)  ❀ (azedes) ~/P/c/spinners> rustc -V
    rustc 1.32.0-nightly (6acbb5b65 2018-11-25)
    

    The problem seems to be in the spinner library, that fails to lock stdout. Not really sure how to debug past that but :woman_shrugging:

    opened by spacekookie 4
  • Converting all stdout to stderr

    Converting all stdout to stderr

    Love the package - but didn't want the spinner outputs to get written to stdout when piping results outside of the program.

    Simple as replacing all print! and println! to eprint! and eprintln!

    question 
    opened by noamteyssier 3
  • Spinner::extended() introduced

    Spinner::extended() introduced

    This is just Spinner::new() with the boxed closure as a third parameter. I'm not sure this is the prettiest solution possible. Example complex_spinner created.

    opened by Tyrn 3
  • Stop printing after calling `stop` (Fixes #26)

    Stop printing after calling `stop` (Fixes #26)

    To consistently stop printing after a call to stop and it's variants, we must join the spawned thread. To support the implementation of the Drop Trait, we store the JoinHandle as an Option in the Spinner struct. This allows us to explicitly join the thread when the Spinner is dropped if it hasn't been explicitly stopped, otherwise it does nothing.

    Fixes #26

    opened by cgati 2
  • Updated stop_inner (fixes #2)

    Updated stop_inner (fixes #2)

    Edited stop_inner to delete the spinner and text when called. This also means the stop_with_newline function isn't necessary anymore. I also updated some documentation to include the new functions like stop_and_persist.

    Only problem I can't find a way to solve is that deleting the spinner and text leaves an empty line behind.

    opened by ad4mx 1
  • Added functions to print a message and symbol after stopping

    Added functions to print a message and symbol after stopping

    Closes #28

    I have added a stop_and_persist function that stops the spinner and then shows a symbol and a message. I have also added succeed, fail, warn, info, and unknown functions that use the stop_and_persist function with a pre-defined symbol (with color and, theoretically, support for windows terminals).

    Note: I might also push out some more features in this pr if it is going to take time (so that there arent many prs from me that sit unmerged). Do let me know if I should use any other approach

    opened by AnishDe12020 1
  • Spinner outputs text after `stop` call

    Spinner outputs text after `stop` call

    I'm facing a regression in spinners in version 3.1.0. In my application I call spinner.stop() and then clear the previous line using crossterm:

    spinner.stop();
    execute!(std::io::stdout(), Clear(ClearType::CurrentLine), cursor::Show);
    

    The line is successfully cleared, but as of version 3.1.0, the spinner will produce output even after being stopped. This behavior is new in 3.1.0 and worked as expected in 3.0.1 (no output is produced after the stop call).

    bug 
    opened by sullivan-sean 1
  • Implement timer and stop symbol

    Implement timer and stop symbol

    Additions:

    • Option to have a timer as part of the spinner.
    • Option to replace the spinner with an alternative symbol when stopping (for signaling success/failure for example).
    • Join the thread when stopping.

    Regarding the joining, in the examples, the thread would most frequently be killed by drop of the Spinner rather than the stop message sent through the channel. This was fine before, but now it's important that the stop method is run before the thread is killed since the stop message carries the timing and replacement symbol. This probably should be integrated with #24 too.

    opened by oersted 1
  • Implemented drop as a synonym for stop

    Implemented drop as a synonym for stop

    Stops the spinner when it goes out of scope.

    Effectively runs the stop function when the spinner variable is dropped, allowing for it to be freed from memory, without calling any extra functions.

    Especially helpful with unforeseen exceptions where the stop function is not manually called, in which case the spinner would continue forever without this trait.

    Implemented the feature from #18

    opened by jewlexx 1
  • Fixes and

    Fixes and "improvements"

    • Fixed an issue with Rust edition 2021 (Unsure what caused the issue, but it is from the base spinner package and happened to me with 2021 and on Windows)
    • Removed dependency on base Spinner package
    • Removed necesity for referencing Spinner enum (Replaced with cloning)
    • Added documentation to the main methods
    • Added a method to stop with new line
    • Added a method to stop and print a message afterwards
    • Changed re-exports

    Things you might wanna check:

    • [x] Changed re-exports
    • [x] Removed necesity for referencing Spinner enum (Replaced with cloning)
    opened by jewlexx 1
  • GIF to demo all spinners

    GIF to demo all spinners

    Hey, thanks for the library! I made a GIF to show all spinners because I want to have an easy way to see/compare which spinner to use. Hope it helps others with same need.

    spinners

    opened by wzulfikar 0
  • Added colors for spinners

    Added colors for spinners

    Added colors for spinners. I didn't really like the termcolor library you recommended, and instead went with a simpler variant. Everything is tested and examples are updated.

    opened by ad4mx 0
  • Add a configurable drop behavior for Spinner

    Add a configurable drop behavior for Spinner

    This commit adds an on_drop method to Spinner, the method is a "Builder method" (called on a Spinner taking ownership and returns a new Spinner instance). The existing Spinner API therefore continue to work as they did before with no changes to methods or their parameters.

    By default, i.e. when on_drop is not used to set the default behavior of a Spinner, its behavior remains the same as prior to this commit. When on_drop is called on a Spinner, a new Spinner instance is returned. If this instance is dropped without any of its stop* methods having been called, then the StopBehavior set in the on_drop call is triggered.

    This change allows the following simple construction:

    {
       let sp = Spinner::new(...).on_drop(StopBehavior::Message("Failed!".into()));
       do_something_fallible()?;
       sp.stop_with_message("Yay, it worked".into());
    }
    

    If do_something_fallible() returns a Result::Ok the Spinner is stopped with the "success" message. Conversely, if do_something_fallible() returns a Result::Err, the Spinner is stopped with the "Failed!" message when it is dropped.

    All feedback is very welcome!

    opened by rustn00b 0
  • Is there a way to place the spinner on a chosen column?

    Is there a way to place the spinner on a chosen column?

    Hi,

    Say, the second console column, instead of the first one by default. It looks like SpinnerBuilder is responsible for customization, but it is unavailable in the spinners context. Or is it just my lack of experience?

    This example does precisely what I want:

    extern crate spinner;
    
    use std::time::Duration;
    use std::thread;
    
    use spinner::SpinnerBuilder;
    
    fn main() {
        let sp = SpinnerBuilder::new("Long Running op!".into()).
            format(|sp, status|{
                format!("   {spin} -- Currently working on: \'{status}\' -- {spin}",
                        spin = sp, status = status)
            }).start();
        thread::sleep(Duration::from_millis(2000));
        sp.message("Updating...".into());
        sp.update("Fixing things...".into());
        thread::sleep(Duration::from_millis(2000));
        sp.message("Done!".into());
        sp.close();
    }
    

    The line

                format!("   {spin} -- Currently working on: \'{status}\' -- {spin}",
    

    Is all I need.

    enhancement 
    opened by Tyrn 4
  • GitHub Actions workflows

    GitHub Actions workflows

    Would you be interested in having GA workflows being added to the repository? I could provide you these workflows:

    • CI workflow triggered on PRs:
      • Does formatting checking
      • Runs clippy
      • Runs tests
    • CD workflow triggered when pushing a git tag:
      • Pushes a new version to crates.io

    Additionally, the following could be done:

    • CI workflow for scheduled spinner updates:
      • Runs a cron job to update the spinners automatically. If updates do take place, a new patch version is published.

    An alternative to the last workflow would be to turn the update_spinners script into a build script. That way, the files are always up-to-date. Compilation would be longer though (maybe 2sec-5sec, depending on the internet connection).

    good first issue 
    opened by mainrs 1
Owner
Francois-Guillaume Ribreau
🌟 #FullStackHacker CTO as a Service @image-charts @cloud-iam @hook0 @netwo-io @killbugtoday @mailpopin ...- Available for consulting
Francois-Guillaume Ribreau
82 fun and easy to use, lightweight, spinners for Rust, with minimal overhead.

Spinners for Rust 82 fun and easy to use, lightweight, spinners for Rust, with minimal overhead, all the way from simple dots, to fun emoji based "spi

Juliette Cordor 2 May 17, 2022
An elegant language for script-kiddies and terminal squatters.

Tonic An elegant language for script-kiddies and terminal squatters. About I started Tonic to complete the Advent of Code 2021. My eventual goal is to

Ryan Chandler 12 Nov 22, 2022
Wena is a micro-framework that provides an elegant starting point for your console application.

Wena was created by Nuno Maduro, and is a Rust Lang micro-framework that provides an elegant starting point for your console application. This project

null 251 Dec 11, 2022
lla - The Elegant ls Alternative

lla - The Elegant ls Alternative Overview lla (Lightweight ls Alternative) is an elegant and efficient command-line utility written in Rust, designed

Mohamed Achaq 4 Jul 31, 2023
A terminal ASCII media player. View images, gifs, videos, webcam, YouTube, etc.. directly in the terminal as ASCII art.

Terminal Media Player View images, videos (files or YouTube links), webcam, etc directly in the terminal as ASCII. All images you see below are just m

Max Curzi 36 May 8, 2023
ask.sh: AI terminal assistant that can read and write your terminal directly!

ask.sh: AI terminal assistant that read from & write to your terminal ask.sh is an AI terminal assistant based on OpenAI APIs such as GPT-3.5/4! What'

hmirin 5 Jun 20, 2023
A simple and efficient terminal UI implementation with ratatui.rs for getting quick insights from csv files right on the terminal

CSV-GREP csv-grep is an intuitive TUI application writting with ratatui.rs for reading, viewing and quickly analysing csv files right on the terminal.

Anthony Ezeabasili 16 Mar 10, 2024
Low-level Rust library for implementing terminal command line interface, like in embedded systems.

Terminal CLI Need to build an interactive command prompt, with commands, properties and with full autocomplete? This is for you. Example, output only

HashMismatch 47 Nov 25, 2022
Rust library for ANSI terminal colours and styles (bold, underline)

rust-ansi-term This is a library for controlling colours and formatting, such as red bold text or blue underlined text, on ANSI terminals. View the Ru

Benjamin Sago 407 Jan 2, 2023
Cross-platform Rust library for coloring and formatting terminal output

Coloring terminal output Documentation term-painter is a cross-platform (i.e. also non-ANSI terminals) Rust library for coloring and formatting termin

Lukas Kalbertodt 75 Jul 28, 2022
A dead simple ANSI terminal color painting library for Rust.

yansi A dead simple ANSI terminal color painting library for Rust. use yansi::Paint; print!("{} light, {} light!", Paint::green("Green"), Paint::red(

Sergio Benitez 169 Dec 25, 2022
(Rust) Coloring terminal so simple you already know how to do it !

Colored Coloring terminal so simple, you already know how to do it! "this is blue".blue(); "this is red".red(); "this is red on blue".red(

Thomas Wickham 1.2k Jan 4, 2023
Cross platform terminal library rust

Cross-platform Terminal Manipulation Library Crossterm is a pure-rust, terminal manipulation library that makes it possible to write cross-platform te

crossterm-rs 2.1k Jan 2, 2023
Build terminal user interfaces and dashboards using Rust

tui-rs tui-rs is a Rust library to build rich terminal user interfaces and dashboards. It is heavily inspired by the Javascript library blessed-contri

Florian Dehau 9.3k Jan 4, 2023
A small command-line application to view images from the terminal written in Rust.

A small command-line application to view images from the terminal written in Rust. It is basically the front-end of viuer

Atanas Yankov 1.9k Jan 3, 2023
A lightweight terminal menu for Rust

youchoose A simple, easy to use command line menu for Rust. Usage There are two methods you need to be familiar with to get started: Menu::new which t

Nathan Thomas 143 Dec 21, 2022
Simple Interactive Terminal Todo App in Rust

todo-rs Simple Interactive Terminal Todo App in Rust Quick Start $ cargo run TODO Controls Keys Description k, j Move cursor up and down Shift+K, Shif

Tsoding 56 Dec 8, 2022
Warp is a blazingly fast, Rust-based terminal that makes you and your team more productive at running, debugging, and deploying code and infrastructure.

Warp is a blazingly fast, Rust-based terminal that makes you and your team more productive at running, debugging, and deploying code and infrastructure.

Warp 10.4k Jan 4, 2023
Replace an app's icon from a png with a single terminal script. Made with Rust

Replace macOS App Icon Replace an app's icon from a png with a single terminal CLI. Made with Rust

Kunal Bagaria 8 Aug 3, 2022