ref #29 Added main method run in worker.

This commit is contained in:
IgorekLoschinin 2021-05-13 00:14:46 +03:00
parent 19290a89c6
commit 918843b05a
3 changed files with 33 additions and 10 deletions

View File

@ -14,7 +14,9 @@ using namespace CopyrighFixer;
int main(int argc, char *argv[]) {
Worker worker;
Worker worker(new Config,
new ConfigParser,
new Signer);
if (!QuasarAppUtils::Params::parseParams(argc, argv)) {
worker.printHelp();
@ -26,5 +28,10 @@ int main(int argc, char *argv[]) {
return 0;
}
bool runProc = worker.run();
if (!runProc) {
return 0;
}
return 0;
}

View File

@ -6,18 +6,39 @@
//#
#include "config.h"
#include "configparser.h"
#include "worker.h"
#include <quasarapp.h>
namespace CopyrighFixer {
Worker::Worker() {
Worker::Worker(
Config *conf,
ConfigParser *confParser,
Signer *subscriber) {
conf_ = conf ?: new Config;
confParser_ = confParser ?: new ConfigParser;
subscriber_ = subscriber ?: new Signer;
}
Worker::~Worker() {
delete conf_;
delete confParser_;
delete subscriber_;
}
bool Worker::run() {
if (!confParser_->parseOptions(*conf_)) {
return false;
}
if (!subscriber_->checkSign(*conf_)) {
return false;
}
return true;
}
void Worker::printHelp() const {

View File

@ -25,16 +25,11 @@ public:
Worker(Config *conf = nullptr,
ConfigParser *confParser = nullptr,
Signer *subscriber = nullptr);
~Worker() {
delete conf_;
delete confParser_;
delete subscriber_;
};
~Worker();
/**
* @brief run It is main method for control of all parsing process.
* @return Returns false if the program terminates with an error.
*/
bool run();