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() {
|
2019-12-17 22:02:40 -06:00
|
|
|
|
|
|
|
|
// Hide cursor
|
|
|
|
|
std::cout << "\e[?25l";
|
|
|
|
|
|
2020-02-03 21:12:33 +01:00
|
|
|
indicators::ProgressBar bar{
|
2020-02-13 14:21:01 +05:30
|
|
|
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},
|
2020-04-06 11:25:54 -07:00
|
|
|
indicators::option::FontStyles{
|
|
|
|
|
std::vector<indicators::FontStyle>{indicators::FontStyle::bold}}
|
2020-02-03 21:12:33 +01:00
|
|
|
};
|
2019-12-17 09:31:43 -06:00
|
|
|
|
2019-12-16 11:03:31 -06:00
|
|
|
// Update bar state
|
|
|
|
|
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
|
2019-12-17 22:02:40 -06:00
|
|
|
std::this_thread::sleep_for(std::chrono::milliseconds(800));
|
|
|
|
|
|
2020-02-03 21:12:33 +01:00
|
|
|
bar.set_option(indicators::option::PostfixText{"Loading dependency 2/4"});
|
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-17 22:02:40 -06:00
|
|
|
std::this_thread::sleep_for(std::chrono::milliseconds(700));
|
|
|
|
|
|
2020-02-03 21:12:33 +01:00
|
|
|
bar.set_option(indicators::option::PostfixText{"Loading dependency 3/4"});
|
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
|
2019-12-17 22:02:40 -06:00
|
|
|
std::this_thread::sleep_for(std::chrono::milliseconds(900));
|
|
|
|
|
|
2020-02-03 21:12:33 +01:00
|
|
|
bar.set_option(indicators::option::PostfixText{"Loaded dependencies!"});
|
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-17 22:02:40 -06:00
|
|
|
bar.mark_as_completed();
|
|
|
|
|
|
|
|
|
|
// Show cursor
|
2019-12-18 12:47:10 -06:00
|
|
|
std::cout << "\e[?25h";
|
2019-12-17 22:02:40 -06:00
|
|
|
|
2019-12-16 11:03:31 -06:00
|
|
|
return 0;
|
|
|
|
|
}
|