Skip to content

moshiba/pbar

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

pbar GitHub GitHub release (latest SemVer including pre-releases)

GitHub code size in bytes Codacy Badge

Low overhead C++ progress bar with a friendly interface

runtime-demo-GIF

Table of Contents

Quickstart

The pbar library is very easy to use, with a simple constructor ProgressBar(${description}, ${total}) and you're ready to go.

Updating the bar is as easy as the construction process, update(${number}) increases/decreases the bar to whatever number you want.

there are example codes in the examples/ directory, see Install for more information.

Simple example

#include "pbar.hpp"
using namespace pbar;

int main() {
    ProgressBar progressbar("outer", 10);
    for (int i = 0; i != 10; ++i) {
        progressbar.update();
    }
}

Nested progress bars

#include "pbar.hpp"
using namespace pbar;
constexpr int test_size1 = 10;
constexpr int test_size2 = 10000000;

int main() {
    ProgressBar progressbar1("outer", test_size1, true);
    for (int i = 0; i != test_size1; ++i) {
        ProgressBar progressbar2("inner", test_size2, true);
        for (int j = 0; j != test_size2; ++j) {
            progressbar2.update();
        }
        progressbar1.update();
    }
}

Install

CMake is the official build system.

Requirements

  • C++11 or higher
  • Ansi-Escape library for terminal render control
  • CMake 3.5 or higher
mkdir build; cd build/

# Config and build
cmake .. && make driver

# execute example
./examples/driver