From 7962c540a8b75d01e5ffc6e7a6a285ebda985d07 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Walenciak?= Date: Sat, 3 Aug 2024 14:01:09 +0200 Subject: [PATCH] Update code --- README.md | 68 +++++++++++++++++++++++++++++++++++++------------------ 1 file changed, 46 insertions(+), 22 deletions(-) diff --git a/README.md b/README.md index 762c1ae..8b843b4 100644 --- a/README.md +++ b/README.md @@ -442,35 +442,59 @@ using namespace indicators; int main() { - ProgressBar bar1{option::BarWidth{50}, option::ForegroundColor{Color::red}, - option::ShowElapsedTime{true}, option::ShowRemainingTime{true}, - option::PrefixText{"5c90d4a2d1a8: Downloading "}}; + auto bar1 = std::make_unique(option::BarWidth{50}, + option::ForegroundColor{Color::red}, + option::ShowElapsedTime{true}, + option::ShowRemainingTime{true}, + option::PrefixText{"5c90d4a2d1a8: Downloading "}, + indicators::option::FontStyles{ + std::vector{indicators::FontStyle::bold}}); - ProgressBar bar2{option::BarWidth{50}, option::ForegroundColor{Color::yellow}, - option::ShowElapsedTime{true}, option::ShowRemainingTime{true}, - option::PrefixText{"22337bfd13a9: Downloading "}}; + auto bar2 = std::make_unique(option::BarWidth{50}, + option::ForegroundColor{Color::yellow}, + option::ShowElapsedTime{true}, + option::ShowRemainingTime{true}, + option::PrefixText{"22337bfd13a9: Downloading "}, + indicators::option::FontStyles{ + std::vector{indicators::FontStyle::bold}}); - ProgressBar bar3{option::BarWidth{50}, option::ForegroundColor{Color::green}, - option::ShowElapsedTime{true}, option::ShowRemainingTime{true}, - option::PrefixText{"10f26c680a34: Downloading "}}; + auto bar3 = std::make_unique(option::BarWidth{50}, + option::ForegroundColor{Color::green}, + option::ShowElapsedTime{true}, + option::ShowRemainingTime{true}, + option::PrefixText{"10f26c680a34: Downloading "}, + indicators::option::FontStyles{ + std::vector{indicators::FontStyle::bold}}); - ProgressBar bar4{option::BarWidth{50}, option::ForegroundColor{Color::white}, - option::ShowElapsedTime{true}, option::ShowRemainingTime{true}, - option::PrefixText{"6364e0d7a283: Downloading "}}; + auto bar4 = std::make_unique(option::BarWidth{50}, + option::ForegroundColor{Color::white}, + option::ShowElapsedTime{true}, + option::ShowRemainingTime{true}, + option::PrefixText{"6364e0d7a283: Downloading "}, + indicators::option::FontStyles{ + std::vector{indicators::FontStyle::bold}}); - ProgressBar bar5{option::BarWidth{50}, option::ForegroundColor{Color::blue}, - option::ShowElapsedTime{true}, option::ShowRemainingTime{true}, - option::PrefixText{"ff1356ba118b: Downloading "}}; + auto bar5 = std::make_unique(option::BarWidth{50}, + option::ForegroundColor{Color::blue}, + option::ShowElapsedTime{true}, + option::ShowRemainingTime{true}, + option::PrefixText{"ff1356ba118b: Downloading "}, + indicators::option::FontStyles{ + std::vector{indicators::FontStyle::bold}}); - ProgressBar bar6{option::BarWidth{50}, option::ForegroundColor{Color::cyan}, - option::ShowElapsedTime{true}, option::ShowRemainingTime{true}, - option::PrefixText{"5a17453338b4: Downloading "}}; + auto bar6 = std::make_unique(option::BarWidth{50}, + option::ForegroundColor{Color::cyan}, + option::ShowElapsedTime{true}, + option::ShowRemainingTime{true}, + option::PrefixText{"5a17453338b4: Downloading "}, + indicators::option::FontStyles{ + std::vector{indicators::FontStyle::bold}}); std::cout << termcolor::bold << termcolor::white << "Pulling image foo:bar/baz\n"; // Construct with 3 progress bars. We'll add 3 more at a later point DynamicProgress bars(bar1, bar2, bar3); - + // Do not hide bars when completed bars.set_option(option::HideBarWhenComplete{false}); @@ -518,7 +542,7 @@ int main() { if (bars[0].is_completed()) { bars[0].set_option(option::PrefixText{"5c90d4a2d1a8: Pull complete "}); // bar1 is completed, adding bar6 - auto i = bars.push_back(bar6); + auto i = bars.push_back(std::move(bar6)); sixth_job = std::thread(job6, i); sixth_job.join(); break; @@ -533,7 +557,7 @@ int main() { if (bars[1].is_completed()) { bars[1].set_option(option::PrefixText{"22337bfd13a9: Pull complete "}); // bar2 is completed, adding bar5 - auto i = bars.push_back(bar5); + auto i = bars.push_back(std::move(bar5)); fifth_job = std::thread(job5, i); fifth_job.join(); break; @@ -548,7 +572,7 @@ int main() { if (bars[2].is_completed()) { bars[2].set_option(option::PrefixText{"10f26c680a34: Pull complete "}); // bar3 is completed, adding bar4 - auto i = bars.push_back(bar4); + auto i = bars.push_back(std::move(bar4)); fourth_job = std::thread(job4, i); fourth_job.join(); break;