Updated README

This commit is contained in:
Pranav Srinivas Kumar
2019-12-17 22:02:40 -06:00
parent a80e4af117
commit 2719604ba9
2 changed files with 59 additions and 31 deletions

View File

@@ -94,42 +94,56 @@ If you'd rather control progress of the bar in discrete steps, consider using `b
</p> </p>
```cpp ```cpp
#include <chrono>
#include <indicators/progress_bar.hpp> #include <indicators/progress_bar.hpp>
#include <thread> #include <thread>
#include <chrono>
int main() { int main() {
// Hide cursor
std::cout << "\e[?25l";
indicators::ProgressBar bar; indicators::ProgressBar bar;
// Configure the bar // Configure the bar
bar.set_bar_width(50); bar.set_bar_width(50);
bar.start_bar_with("["); bar.start_bar_with("[");
bar.fill_bar_progress_with("="); bar.fill_bar_progress_with("");
bar.lead_bar_progress_with(">"); bar.lead_bar_progress_with("");
bar.fill_bar_remainder_with(" "); bar.fill_bar_remainder_with("-");
bar.end_bar_with("]"); bar.end_bar_with(" ]");
bar.set_postfix_text("Getting started"); bar.set_postfix_text("Loading dependency 1/4");
bar.set_foreground_color(indicators::Color::GREEN); bar.set_foreground_color(indicators::Color::CYAN);
// Update bar state // Update bar state
bar.set_progress(10); // 10% done bar.set_progress(10); // 10% done
// do some work // do some work
std::this_thread::sleep_for(std::chrono::milliseconds(100)); std::this_thread::sleep_for(std::chrono::milliseconds(800));
bar.set_postfix_text("Loading dependency 2/4");
bar.set_progress(30); // 30% done bar.set_progress(30); // 30% done
// do some more work // do some more work
std::this_thread::sleep_for(std::chrono::milliseconds(600)); std::this_thread::sleep_for(std::chrono::milliseconds(700));
bar.set_postfix_text("Loading dependency 3/4");
bar.set_progress(65); // 65% done bar.set_progress(65); // 65% done
// do final bit of work // do final bit of work
std::this_thread::sleep_for(std::chrono::milliseconds(300)); std::this_thread::sleep_for(std::chrono::milliseconds(900));
bar.set_postfix_text("Loaded dependencies!");
bar.set_progress(100); // all done bar.set_progress(100); // all done
bar.mark_as_completed();
// Show cursor
std::cout << "\e[?25h";
return 0; return 0;
} }
``` ```

View File

@@ -3,36 +3,50 @@
#include <thread> #include <thread>
int main() { int main() {
// Hide cursor
std::cout << "\e[?25l";
indicators::ProgressBar bar; indicators::ProgressBar bar;
// Configure the bar // Configure the bar
bar.set_bar_width(50); bar.set_bar_width(50);
bar.start_bar_with("["); bar.start_bar_with("[");
bar.fill_bar_progress_with("="); bar.fill_bar_progress_with("");
bar.lead_bar_progress_with(">"); bar.lead_bar_progress_with("");
bar.fill_bar_remainder_with(" "); bar.fill_bar_remainder_with("-");
bar.end_bar_with("]"); bar.end_bar_with(" ]");
bar.set_postfix_text("Getting started"); bar.set_postfix_text("Loading dependency 1/4");
bar.set_foreground_color(indicators::Color::GREEN); bar.set_foreground_color(indicators::Color::CYAN);
// Update bar state // Update bar state
bar.set_progress(10); // 10% done bar.set_progress(10); // 10% done
// do some work // do some work
std::this_thread::sleep_for(std::chrono::milliseconds(100)); std::this_thread::sleep_for(std::chrono::milliseconds(800));
bar.set_postfix_text("Loading dependency 2/4");
bar.set_progress(30); // 30% done bar.set_progress(30); // 30% done
// do some more work // do some more work
std::this_thread::sleep_for(std::chrono::milliseconds(600)); std::this_thread::sleep_for(std::chrono::milliseconds(700));
bar.set_postfix_text("Loading dependency 3/4");
bar.set_progress(65); // 65% done bar.set_progress(65); // 65% done
// do final bit of work // do final bit of work
std::this_thread::sleep_for(std::chrono::milliseconds(300)); std::this_thread::sleep_for(std::chrono::milliseconds(900));
bar.set_postfix_text("Loaded dependencies!");
bar.set_progress(100); // all done bar.set_progress(100); // all done
bar.mark_as_completed();
// Show cursor
std::cout << "\e[?25h";
return 0; return 0;
} }