ProgressBar API change - make ProgressBar constructible with options

This commit is contained in:
pilarski
2020-02-03 21:12:33 +01:00
parent 3c8975aa34
commit 46bccdcc1c
7 changed files with 119 additions and 117 deletions

View File

@@ -7,17 +7,16 @@ int main() {
// Hide cursor
std::cout << "\e[?25l";
indicators::ProgressBar bar;
// 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("Loading dependency 1/4");
bar.set_foreground_color(indicators::Color::CYAN);
indicators::ProgressBar bar{
indicators::option::BarWidth{50},
indicators::option::Start{"["},
indicators::option::Fill{""},
indicators::option::Lead{""},
indicators::option::Remainder{"-"},
indicators::option::End{" ]"},
indicators::option::PostfixText{"Loading dependency 1/4"},
indicators::option::ForegroundColor{indicators::Color::CYAN},
};
// Update bar state
bar.set_progress(10); // 10% done
@@ -25,21 +24,21 @@ int main() {
// do some work
std::this_thread::sleep_for(std::chrono::milliseconds(800));
bar.set_postfix_text("Loading dependency 2/4");
bar.set_option(indicators::option::PostfixText{"Loading dependency 2/4"});
bar.set_progress(30); // 30% done
// do some more work
std::this_thread::sleep_for(std::chrono::milliseconds(700));
bar.set_postfix_text("Loading dependency 3/4");
bar.set_option(indicators::option::PostfixText{"Loading dependency 3/4"});
bar.set_progress(65); // 65% done
// do final bit of work
std::this_thread::sleep_for(std::chrono::milliseconds(900));
bar.set_postfix_text("Loaded dependencies!");
bar.set_option(indicators::option::PostfixText{"Loaded dependencies!"});
bar.set_progress(100); // all done