All Projects → schollz → Progressbar

schollz / Progressbar

Licence: mit
A really basic thread-safe progress bar for Golang applications

Programming Languages

go
31211 projects - #10 most used programming language

Projects that are alternatives of or similar to Progressbar

Python Progressbar
Progressbar 2 - A progress bar for Python 2 and Python 3 - "pip install progressbar2"
Stars: ✭ 682 (-69.17%)
Mutual labels:  terminal, library, progress-bar, progressbar
Nve
Run any command on specific Node.js versions
Stars: ✭ 531 (-75.99%)
Mutual labels:  terminal, command-line, library
Node.cli Progress
⌛️ easy to use progress-bar for command-line/terminal applications
Stars: ✭ 466 (-78.93%)
Mutual labels:  command-line, progress-bar, progressbar
Bat
A cat(1) clone with wings.
Stars: ✭ 30,833 (+1293.9%)
Mutual labels:  terminal, command-line, hacktoberfest
Progress bar
Command-line progress bars and spinners for Elixir.
Stars: ✭ 281 (-87.3%)
Mutual labels:  terminal, progress-bar, progressbar
Castero
TUI podcast client for the terminal
Stars: ✭ 375 (-83.05%)
Mutual labels:  terminal, command-line, hacktoberfest
Rich
Rich is a Python library for rich text and beautiful formatting in the terminal.
Stars: ✭ 31,664 (+1331.46%)
Mutual labels:  terminal, hacktoberfest, progress-bar
Tqdm
A Fast, Extensible Progress Bar for Python and CLI
Stars: ✭ 20,632 (+832.73%)
Mutual labels:  terminal, progress-bar, progressbar
Tldr
📚 Collaborative cheatsheets for console commands
Stars: ✭ 36,408 (+1545.93%)
Mutual labels:  terminal, command-line, hacktoberfest
Missme
Same Old Android Progress Dialog
Stars: ✭ 49 (-97.78%)
Mutual labels:  library, progress-bar, progressbar
Navi
An interactive cheatsheet tool for the command-line
Stars: ✭ 10,055 (+354.57%)
Mutual labels:  terminal, command-line, hacktoberfest
Alive Progress
A new kind of Progress Bar, with real-time throughput, ETA, and very cool animations!
Stars: ✭ 2,940 (+32.91%)
Mutual labels:  terminal, progress-bar, progressbar
Spinner
Go (golang) package with 90 configurable terminal spinner/progress indicators.
Stars: ✭ 1,637 (-25.99%)
Mutual labels:  terminal, progress-bar, progressbar
Clifx
Declarative framework for building command line interfaces
Stars: ✭ 900 (-59.31%)
Mutual labels:  terminal, command-line, hacktoberfest
Ruby Progressbar
Ruby/ProgressBar is a text progress bar library for Ruby.
Stars: ✭ 1,378 (-37.7%)
Mutual labels:  terminal, progress-bar, progressbar
Typin
Declarative framework for interactive CLI applications
Stars: ✭ 126 (-94.3%)
Mutual labels:  terminal, command-line, library
Chocobar
The usual Snackbar with more 🍫 and colours 🎉
Stars: ✭ 110 (-95.03%)
Mutual labels:  hacktoberfest, library
Httpcat
httpcat is a simple utility for constructing raw HTTP requests on the command line.
Stars: ✭ 109 (-95.07%)
Mutual labels:  terminal, command-line
Goto
Navigate long command lines using a minimalistic char-based decision tree.
Stars: ✭ 112 (-94.94%)
Mutual labels:  terminal, command-line
Kittehircclientlib
An IRC client library in Java
Stars: ✭ 116 (-94.76%)
Mutual labels:  hacktoberfest, library

progressbar

CI go report card coverage godocs

A very simple thread-safe progress bar which should work on every OS without problems. I needed a progressbar for croc and everything I tried had problems, so I made another one. In order to be OS agnostic I do not plan to support multi-line outputs.

Install

go get -u github.com/schollz/progressbar/v3

Usage

Basic usage

bar := progressbar.Default(100)
for i := 0; i < 100; i++ {
    bar.Add(1)
    time.Sleep(40 * time.Millisecond)
}

which looks like:

Example of basic bar

I/O operations

The progressbar implements an io.Writer so it can automatically detect the number of bytes written to a stream, so you can use it as a progressbar for an io.Reader.

req, _ := http.NewRequest("GET", "https://dl.google.com/go/go1.14.2.src.tar.gz", nil)
resp, _ := http.DefaultClient.Do(req)
defer resp.Body.Close()

f, _ := os.OpenFile("go1.14.2.src.tar.gz", os.O_CREATE|os.O_WRONLY, 0644)
defer f.Close()

bar := progressbar.DefaultBytes(
    resp.ContentLength,
    "downloading",
)
io.Copy(io.MultiWriter(f, bar), resp.Body)

which looks like:

Example of download bar

Progress bar with unknown length

A progressbar with unknown length is a spinner. Any bar with -1 length will automatically convert it to a spinner with a customizable spinner type. For example, the above code can be run and set the resp.ContentLength to -1.

which looks like:

Example of download bar with unknown length

Customization

There is a lot of customization that you can do - change the writer, the color, the width, description, theme, etc. See all the options.

bar := progressbar.NewOptions(1000,
    progressbar.OptionSetWriter(ansi.NewAnsiStdout()),
    progressbar.OptionEnableColorCodes(true),
    progressbar.OptionShowBytes(true),
    progressbar.OptionSetWidth(15),
    progressbar.OptionSetDescription("[cyan][1/3][reset] Writing moshable file..."),
    progressbar.OptionSetTheme(progressbar.Theme{
        Saucer:        "[green]=[reset]",
        SaucerHead:    "[green]>[reset]",
        SaucerPadding: " ",
        BarStart:      "[",
        BarEnd:        "]",
    }))
for i := 0; i < 1000; i++ {
    bar.Add(1)
    time.Sleep(5 * time.Millisecond)
}

which looks like:

Example of customized bar

Contributing

Pull requests are welcome. Feel free to...

  • Revise documentation
  • Add new features
  • Fix bugs
  • Suggest improvements

Thanks

Thanks @Dynom for massive improvements in version 2.0!

Thanks @CrushedPixel for adding descriptions and color code support!

Thanks @MrMe42 for adding some minor features!

Thanks @tehstun for some great PRs!

Thanks @Benzammour and @haseth for helping create v3!

Thanks @briandowns for compiling the list of spinners.

License

MIT

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