Code Monkey home page Code Monkey logo

spinners's Introduction

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

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

❀️ Shameless plug

200083093-cf48fcab-d95c-4a59-ac66-6e167dd33e7e

Install

See Cargo page

Usage

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

fn main() {
    let mut 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, James Cordor

spinners's People

Contributors

anishde12020 avatar cgati avatar fgribreau avatar io12 avatar jewlexx avatar ksk001100 avatar lrazovic avatar noamteyssier avatar oersted avatar wtachau avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

spinners's Issues

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).

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).

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.

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

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!

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 πŸ€·β€β™€οΈ

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.

Can we stop with final timer?

When we create a spinner with Spinner::with_timer, after issuing a stop I'd like to add a message with the final timer : Eg: Took xx seconds or even access the final timer from the spinner.

let mut sp = Spinner::with_timer(Spinners::Dots3, "Download...".into());
sp.stop_and_persist_with_timer("βœ”", "Download Complete!".into());
// or
sp.stop_and_persist("βœ”", "Download Complete!".into());
let final_time : &str = sp.get_final_time();
println!("Took {} long.", final_time);

Function to add a symbol as well as text to the spinner

Currently, there are two functions, one for stopping the spinner with a symbol and one for stopping it with a text. However, it would be awesome if we could supply a custom symbol as well as custom text. Theoretically, I could supply the symbol along with the message but that means more code from the user's side.

We can also have functions like succeed and fail which will have a preset symbol like a green tick or red cross.

I will also try to make a pr for this

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.