• Stars
    star
    575
  • Rank 74,631 (Top 2 %)
  • Language
    Rust
  • License
    MIT License
  • Created over 8 years ago
  • Updated 4 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Console progress bar for Rust

Terminal progress bar for Rust

Latest version License Docs Build Status Gitter

Console progress bar for Rust Inspired from pb, support and tested on MacOS, Linux and Windows

Screenshot

Documentation

Examples

  1. simple example
use pbr::ProgressBar;
use std::thread;

fn main() {
    let count = 1000;
    let mut pb = ProgressBar::new(count);
    pb.format("โ•ขโ–Œโ–Œโ–‘โ•Ÿ");
    for _ in 0..count {
        pb.inc();
        thread::sleep_ms(200);
    }
    pb.finish_print("done");
}
  1. MultiBar example. see full example here
use std::thread;
use pbr::MultiBar;
use std::time::Duration;

fn main() {
    let mut mb = MultiBar::new();
    let count = 100;
    mb.println("Application header:");

    let mut p1 = mb.create_bar(count);
    let _ = thread::spawn(move || {
        for _ in 0..count {
            p1.inc();
            thread::sleep(Duration::from_millis(100));
        }
        // notify the multibar that this bar finished.
        p1.finish();
    });

    mb.println("add a separator between the two bars");

    let mut p2 = mb.create_bar(count * 2);
    let _ = thread::spawn(move || {
        for _ in 0..count * 2 {
            p2.inc();
            thread::sleep(Duration::from_millis(100));
        }
        // notify the multibar that this bar finished.
        p2.finish();
    });

    // start listen to all bars changes.
    // this is a blocking operation, until all bars will finish.
    // to ignore blocking, you can run it in a different thread.
    mb.listen();
}
  1. Broadcast writing (simple file copying)
#![feature(io)]
use std::io::copy;
use std::io::prelude::*;
use std::fs::File;
use pbr::{ProgressBar, Units};

fn main() {
    let mut file = File::open("/usr/share/dict/words").unwrap();
    let n_bytes = file.metadata().unwrap().len() as usize;
    let mut pb = ProgressBar::new(n_bytes);
    pb.set_units(Units::Bytes);
    let mut handle = File::create("copy-words").unwrap().broadcast(&mut pb);
    copy(&mut file, &mut handle).unwrap();
    pb.finish_print("done");
}

License

MIT

More Repositories

1

golang-cheat-sheet

An overview of Go syntax and features.
8,117
star
2

angular-filter

Bunch of useful filters for AngularJS (with no external dependencies!)
JavaScript
2,928
star
3

envsubst

Environment variables substitution for Go
Go
702
star
4

djson

Fast Go decoder for dynamic JSON
Go
603
star
5

reflect-examples

Bunch of examples for dealing with the reflect package
542
star
6

rql

Resource Query Language for REST
Go
324
star
7

syncmap

A typed implementation of the Go sync.Map using code generation
Go
253
star
8

mark

A markdown processor written in Go. built for fun.
Go
204
star
9

play

Play something while waiting for your command to finish
Go
182
star
10

kinesis-producer

An aggregated records producer for Amazon Kinesis
Go
146
star
11

enter

A CLI for generating ER diagrams for Ent schema
Go
127
star
12

ng-pipes

Bunch of useful pipes for Angular2 (with no external dependencies!)
TypeScript
119
star
13

tree

An implementation of the Unix tree command written in Go, that can be used programmatically
Go
85
star
14

agile

Like Underscore, but with zero callbacks and really more fun, v0.0.2
JavaScript
70
star
15

ent-graphql-example

The code for https://entgo.io/docs/tutorial-setup
Go
60
star
16

doqmentdb

A Promise-Based DocumentDB ODM Client for NodeJS
JavaScript
51
star
17

ng-translation

Fast, Easy and Dynamic translation for AngularJS
JavaScript
43
star
18

pb-scala

Console progress bar for Scala
Scala
37
star
19

documentdb

Go driver for Microsoft Azure DocumentDB
Go
33
star
20

expect

Minimalistic BDD-style assertions for Go (inspired by expect.js)
Go
32
star
21

deep-keys

Create an array composed of the own enumerable property names (including nested) of an object.
JavaScript
23
star
22

lease

Generic lease implementation using DynamoDB
Go
21
star
23

angular-code-mirror

2 way binding codemirror for AngularJS based on google-prettify
JavaScript
13
star
24

entclean

Clean ent/schemas
Go
11
star
25

errors

An experimental error handling package for Go
Go
10
star
26

clog

Pretty colorful cli logger for NodeJS(with table, success and more...)
JavaScript
9
star
27

entspatial

An example repository for working with MySQL spatial data types in ent
Go
7
star
28

s3tree

s3tree is a tree command for Amazon S3
Go
6
star
29

gotips-talk-2018

"Did you know that..." talk. Go-Israel meetup, Jan 2018
Go
6
star
30

maman14

maman14 - assembler
C
5
star
31

go-documentdb-example

A users CRUD app using Martini and DocumentDB
Go
4
star
32

obj-parse

Get and Set object properties in a Fast and Elegant way. (with caching and no dependencies!)
JavaScript
4
star
33

entsize

Print ent/schema size
Go
3
star
34

obj-del

Remove multiple keys by path - safety.
JavaScript
3
star
35

flag.js

cli flag parsing
JavaScript
2
star
36

dynamose

A Promise-Based DynamoDB Client
JavaScript
2
star
37

stringify.js

like JSON.stringify, but more sense
JavaScript
1
star
38

mark-cli

Mark command-line tool
Go
1
star
39

koa-documentdb-example

A users CRUD app using Koa and DoQmentDB(DocumentDB wrapper)
JavaScript
1
star
40

obj-is

is-function's creator
JavaScript
1
star
41

entraffle

A raffle for Ent Discord members
Go
1
star
42

ent-sync-example

The code for https://entgo.io/blog/2021/11/1/sync-objects-in-external-database
Go
1
star