#bar #terminal #customizable #loading

loadingbar

A simple loading bar for the terminal

2 stable releases

1.0.1 Jan 15, 2023

#32 in #bar

MIT license

6KB

loadingbar

A simple, customizable loading bar for the terminal written in rust

Usage

Default loading bar

use loadingbar::LoadingBar;

fn main() {
    let bar = LoadingBar::new();
    bar.start();
}

Custom loading bar

use loadingbar::LoadingBar;

fn main() {
    let bar = LoadingBar::new_with_config(
        std::time::Duration::from_secs(10), // how long the bar will take to complete
        '*', // the character to use for the progress bar
        30, // the length of the bar in characters
        String::from("Loading.. "), // prefix message (Loading.. [##########      ])
    );
    bar.start();
}

lib.rs:

A simple, customizable loading bar for the terminal.

This crate provides a simple loading bar for the terminal that allows for easy customization.

The loading bar will only work on terminals that support ANSI escape codes. (Most modern terminals do except for Windows Command Prompt)

Examples

Default configuration

use loadingbar::LoadingBar;

fn main() {
    let bar = LoadingBar::new(); // create a new default loading bar
    bar.start(); // starts the loading animation
}

Custom configuration

use loadingbar::LoadingBar;

fn main() {
   let bar = LoadingBar::new_with_config(
      std::time::Duration::from_secs(10), // how long the bar will take to complete
     '*', // the character to use for the progress bar
     30, // the length of the bar in characters
     String::from("Loading.. "), // prefix message (Loading.. [##########      ])
  );

  bar.start(); // starts the loading animation
}

No runtime deps