From f047b4bfceb8210448ed38f24f1b33f0c6f574a5 Mon Sep 17 00:00:00 2001 From: Pranav Date: Tue, 3 Dec 2019 20:43:32 -0600 Subject: [PATCH] Update README.md --- README.md | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/README.md b/README.md index e8187f2..41f08cf 100644 --- a/README.md +++ b/README.md @@ -1 +1,46 @@ # progress + +## Progress Bar + +```cpp +#include + +int main() { + ProgressBar bar; + + // Configure progress bar + bar.bar_width(50); + bar.start_with("["); + bar.fill_progress_with("■"); + bar.lead_progress_with("■"); + bar.fill_remainder_with("-"); + bar.end_with("]"); + + // As configured, the bar will look like this: + // + // [■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■-------------] 70% + // + // + + auto job = [&bar]() { + while(true) { + if (bar.completed()) + break; + bar.tick(); + std::this_thread::sleep_for(std::chrono::milliseconds(100)); + } + }; + + std::thread first_thread(job); + std::thread second_thread(job); + std::thread third_thread(job); + std::thread last_thread(job); + + first_thread.join(); + second_thread.join(); + third_thread.join(); + last_thread.join(); + + return 0; +} +```