All Projects → cheggaaa → Pb

cheggaaa / Pb

Licence: bsd-3-clause
Console progress bar for Golang

Programming Languages

go
31211 projects - #10 most used programming language

Projects that are alternatives of or similar to Pb

Progressbar
A really basic thread-safe progress bar for Golang applications
Stars: ✭ 2,212 (-28.14%)
Mutual labels:  terminal, progress-bar
Tqdm
A Fast, Extensible Progress Bar for Python and CLI
Stars: ✭ 20,632 (+570.31%)
Mutual labels:  terminal, progress-bar
Progress bar
Command-line progress bars and spinners for Elixir.
Stars: ✭ 281 (-90.87%)
Mutual labels:  terminal, progress-bar
Rich
Rich is a Python library for rich text and beautiful formatting in the terminal.
Stars: ✭ 31,664 (+928.72%)
Mutual labels:  terminal, progress-bar
Ruby Progressbar
Ruby/ProgressBar is a text progress bar library for Ruby.
Stars: ✭ 1,378 (-55.23%)
Mutual labels:  terminal, progress-bar
Mpb
multi progress bar for Go cli applications
Stars: ✭ 1,221 (-60.33%)
Mutual labels:  terminal, progress-bar
Python Progressbar
Progressbar 2 - A progress bar for Python 2 and Python 3 - "pip install progressbar2"
Stars: ✭ 682 (-77.84%)
Mutual labels:  terminal, progress-bar
Spinner
Go (golang) package with 90 configurable terminal spinner/progress indicators.
Stars: ✭ 1,637 (-46.82%)
Mutual labels:  terminal, progress-bar
Alive Progress
A new kind of Progress Bar, with real-time throughput, ETA, and very cool animations!
Stars: ✭ 2,940 (-4.48%)
Mutual labels:  terminal, progress-bar
Beerprogressview
A library that lets you create a beer styled progress view with bubbles and all! (hic) 🍺
Stars: ✭ 230 (-92.53%)
Mutual labels:  progress-bar
Gmusicapi Scripts
https://github.com/thebigmunch/google-music-scripts
Stars: ✭ 237 (-92.3%)
Mutual labels:  terminal
Cool Retro Term
A good looking terminal emulator which mimics the old cathode display...
Stars: ✭ 15,532 (+404.61%)
Mutual labels:  terminal
Termsql
Convert text from a file or from stdin into SQL table and query it instantly. Uses sqlite as backend. The idea is to make SQL into a tool on the command line or in scripts.
Stars: ✭ 230 (-92.53%)
Mutual labels:  terminal
Code Minimap
🛰 A high performance code minimap render.
Stars: ✭ 235 (-92.37%)
Mutual labels:  terminal
Lsix
Like "ls", but for images. Shows thumbnails in terminal using sixel graphics.
Stars: ✭ 2,635 (-14.39%)
Mutual labels:  terminal
Nord Alacritty
An arctic, north-bluish clean and elegant Alacritty color scheme.
Stars: ✭ 238 (-92.27%)
Mutual labels:  terminal
Spaceship Prompt
🚀⭐ A Zsh prompt for Astronauts
Stars: ✭ 15,748 (+411.63%)
Mutual labels:  terminal
Wttr.in
⛅ The right way to check the weather
Stars: ✭ 16,345 (+431.03%)
Mutual labels:  terminal
Term Sheets
Create animated terminal presentations. Export as SVG, animated GIF, or HTML+CSS
Stars: ✭ 243 (-92.11%)
Mutual labels:  terminal
Chattt
❯❯❯ Chat without leaving your terminal
Stars: ✭ 239 (-92.24%)
Mutual labels:  terminal

Terminal progress bar for Go

Coverage Status

Installation

go get github.com/cheggaaa/pb/v3

Documentation for v1 bar available here.

Quick start

package main

import (
	"time"

	"github.com/cheggaaa/pb/v3"
)

func main() {
	count := 100000

	// create and start new bar
	bar := pb.StartNew(count)

	// start bar from 'default' template
	// bar := pb.Default.Start(count)

	// start bar from 'simple' template
	// bar := pb.Simple.Start(count)

	// start bar from 'full' template
	// bar := pb.Full.Start(count)

	for i := 0; i < count; i++ {
		bar.Increment()
		time.Sleep(time.Millisecond)
	}

	// finish bar
	bar.Finish()
}

Result will be like this:

> go run test.go
37158 / 100000 [---------------->_______________________________] 37.16% 916 p/s

Settings

// create bar
bar := pb.New(count)

// refresh info every second (default 200ms)
bar.SetRefreshRate(time.Second)

// force set io.Writer, by default it's os.Stderr
bar.SetWriter(os.Stdout)

// bar will format numbers as bytes (B, KiB, MiB, etc)
bar.Set(pb.Bytes, true)

// bar use SI bytes prefix names (B, kB) instead of IEC (B, KiB)
bar.Set(pb.SIBytesPrefix, true)

// set custom bar template
bar.SetTemplateString(myTemplate)

// check for error after template set
if err := bar.Err(); err != nil {
    return
}

// start bar
bar.Start()

Progress bar for IO Operations

package main

import (
	"crypto/rand"
	"io"
	"io/ioutil"

	"github.com/cheggaaa/pb/v3"
)

func main() {
	var limit int64 = 1024 * 1024 * 500

	// we will copy 500 MiB from /dev/rand to /dev/null
	reader := io.LimitReader(rand.Reader, limit)
	writer := ioutil.Discard

	// start new bar
	bar := pb.Full.Start64(limit)

	// create proxy reader
	barReader := bar.NewProxyReader(reader)

	// copy from proxy reader
	io.Copy(writer, barReader)

	// finish bar
	bar.Finish()
}

Custom Progress Bar templates

Rendering based on builtin text/template package. You can use existing pb's elements or create you own.

All available elements are described in the element.go file.

All in one example:

tmpl := `{{ red "With funcs:" }} {{ bar . "<" "-" (cycle . "↖" "↗" "↘" "↙" ) "." ">"}} {{speed . | rndcolor }} {{percent .}} {{string . "my_green_string" | green}} {{string . "my_blue_string" | blue}}`

// start bar based on our template
bar := pb.ProgressBarTemplate(tmpl).Start64(limit)

// set values for string elements
bar.Set("my_green_string", "green").Set("my_blue_string", "blue")
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].