2019-12-17 09:31:43 -06:00
|
|
|
#include <chrono>
|
2019-12-16 11:03:31 -06:00
|
|
|
#include <indicators/progress_bar.hpp>
|
|
|
|
|
#include <thread>
|
|
|
|
|
|
|
|
|
|
int main() {
|
|
|
|
|
indicators::ProgressBar bar;
|
2019-12-17 09:31:43 -06:00
|
|
|
|
2019-12-16 11:03:31 -06:00
|
|
|
// Configure the bar
|
|
|
|
|
bar.set_bar_width(50);
|
|
|
|
|
bar.start_bar_with("[");
|
|
|
|
|
bar.fill_bar_progress_with("=");
|
|
|
|
|
bar.lead_bar_progress_with(">");
|
|
|
|
|
bar.fill_bar_remainder_with(" ");
|
|
|
|
|
bar.end_bar_with("]");
|
|
|
|
|
bar.set_postfix_text("Getting started");
|
2019-12-17 09:31:43 -06:00
|
|
|
bar.set_foreground_color(indicators::Color::GREEN);
|
|
|
|
|
|
2019-12-16 11:03:31 -06:00
|
|
|
// Update bar state
|
2019-12-17 09:31:43 -06:00
|
|
|
|
2019-12-16 11:03:31 -06:00
|
|
|
bar.set_progress(10); // 10% done
|
2019-12-17 09:31:43 -06:00
|
|
|
|
2019-12-16 11:03:31 -06:00
|
|
|
// do some work
|
|
|
|
|
std::this_thread::sleep_for(std::chrono::milliseconds(100));
|
2019-12-17 09:31:43 -06:00
|
|
|
|
2019-12-16 11:03:31 -06:00
|
|
|
bar.set_progress(30); // 30% done
|
2019-12-17 09:31:43 -06:00
|
|
|
|
|
|
|
|
// do some more work
|
2019-12-16 11:03:31 -06:00
|
|
|
std::this_thread::sleep_for(std::chrono::milliseconds(600));
|
2019-12-17 09:31:43 -06:00
|
|
|
|
2019-12-16 11:03:31 -06:00
|
|
|
bar.set_progress(65); // 65% done
|
2019-12-17 09:31:43 -06:00
|
|
|
|
2019-12-16 11:03:31 -06:00
|
|
|
// do final bit of work
|
|
|
|
|
std::this_thread::sleep_for(std::chrono::milliseconds(300));
|
2019-12-17 09:31:43 -06:00
|
|
|
|
2019-12-16 11:03:31 -06:00
|
|
|
bar.set_progress(100); // all done
|
2019-12-17 09:31:43 -06:00
|
|
|
|
2019-12-16 11:03:31 -06:00
|
|
|
return 0;
|
|
|
|
|
}
|