Revision 6248f75f
Added by david.sorber over 2 years ago
| src/copytool_main.cc | ||
|---|---|---|
|
/********************************************************************
|
||
|
* CONFIDENTIAL - All source code is the propriety and confidential *
|
||
|
* information of David Sorber. *
|
||
|
* *
|
||
|
* Copyright 2024 David Sorber *
|
||
|
* Unpublished -- all rights reserved under the copyright laws *
|
||
|
* of the United States. *
|
||
|
********************************************************************/
|
||
|
|
||
|
#include <chrono>
|
||
|
#include <cstdint>
|
||
|
#include <filesystem>
|
||
|
#include <iostream>
|
||
| ... | ... | |
|
#include <thread>
|
||
|
|
||
|
#include "CLI11.hpp"
|
||
|
#include "indicators.hpp"
|
||
|
|
||
|
#include "CopyManagerOptions.h"
|
||
|
#include "CopyManager.h"
|
||
| ... | ... | |
|
|
||
|
namespace sfs = std::filesystem;
|
||
|
|
||
|
const std::string VERSION("v0.1.1");
|
||
|
const std::string VERSION("v0.2.0");
|
||
|
|
||
|
const std::string BOLD{"\033[1m"};
|
||
|
const std::string ENDC{"\033[0m"};
|
||
| ... | ... | |
|
const std::string YELLOW{"\033[33m"};
|
||
|
const std::string PURPLE{"\033[35m"};
|
||
|
const std::string LBLUE{"\033[1;34m"};
|
||
|
const std::string UP_ONE = "\033[1A";
|
||
|
|
||
|
|
||
|
int main(int argc, char** argv)
|
||
| ... | ... | |
|
|
||
|
// Create the copy manager and run it
|
||
|
DBS::CopyManager manager(options);
|
||
|
int rc = manager.run();
|
||
|
|
||
|
// The callback structure requires a global
|
||
|
indicators::BlockProgressBar pBarEta{
|
||
|
indicators::option::BarWidth{80},
|
||
|
indicators::option::Start{"["},
|
||
|
indicators::option::End{"]"},
|
||
|
indicators::option::PrefixText{"Complete: "},
|
||
|
indicators::option::ShowElapsedTime{true},
|
||
|
indicators::option::ShowRemainingTime{true},
|
||
|
};
|
||
|
|
||
|
|
||
|
// Run the manager
|
||
|
manager.run();
|
||
|
|
||
|
indicators::show_console_cursor(false);
|
||
|
while (manager.isRunning())
|
||
|
{
|
||
|
// Calculate percent complete
|
||
|
double percent = (static_cast<double>(manager.getProcessedEntries()) /
|
||
|
manager.getTotalEntries()) * 100;
|
||
|
|
||
|
pBarEta.set_progress(percent);
|
||
|
pBarEta.set_option(indicators::option::PostfixText{ " -- " +
|
||
|
std::to_string(manager.getProcessedEntries()) + "/" +
|
||
|
std::to_string(manager.getTotalEntries())
|
||
|
});
|
||
|
|
||
|
|
||
|
std::this_thread::sleep_for(std::chrono::milliseconds(100));
|
||
|
std::cout << std::endl << UP_ONE;
|
||
|
}
|
||
|
|
||
|
int rc = manager.waitForComplete();
|
||
|
|
||
|
pBarEta.set_progress(100.0);
|
||
|
pBarEta.set_option(indicators::option::PostfixText{" -- " +
|
||
|
std::to_string(manager.getProcessedEntries()) + "/" +
|
||
|
std::to_string(manager.getTotalEntries())
|
||
|
});
|
||
|
pBarEta.mark_as_completed();
|
||
|
indicators::show_console_cursor(true);
|
||
|
std::cout << std::endl;
|
||
|
|
||
|
return rc;
|
||
|
}
|
||
Add progress bar; version: 0.2.0.