mirror of
https://github.com/QuasarApp/CopyrightFixer.git
synced 2025-04-26 17:54:42 +00:00
ref #29 Added main method run in worker.
This commit is contained in:
parent
19290a89c6
commit
918843b05a
@ -14,7 +14,9 @@ using namespace CopyrighFixer;
|
|||||||
|
|
||||||
int main(int argc, char *argv[]) {
|
int main(int argc, char *argv[]) {
|
||||||
|
|
||||||
Worker worker;
|
Worker worker(new Config,
|
||||||
|
new ConfigParser,
|
||||||
|
new Signer);
|
||||||
|
|
||||||
if (!QuasarAppUtils::Params::parseParams(argc, argv)) {
|
if (!QuasarAppUtils::Params::parseParams(argc, argv)) {
|
||||||
worker.printHelp();
|
worker.printHelp();
|
||||||
@ -26,5 +28,10 @@ int main(int argc, char *argv[]) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool runProc = worker.run();
|
||||||
|
if (!runProc) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -6,18 +6,39 @@
|
|||||||
//#
|
//#
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
#include "configparser.h"
|
||||||
#include "worker.h"
|
#include "worker.h"
|
||||||
#include <quasarapp.h>
|
#include <quasarapp.h>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
namespace CopyrighFixer {
|
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() {
|
bool Worker::run() {
|
||||||
return false;
|
|
||||||
|
if (!confParser_->parseOptions(*conf_)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!subscriber_->checkSign(*conf_)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Worker::printHelp() const {
|
void Worker::printHelp() const {
|
||||||
|
@ -25,16 +25,11 @@ public:
|
|||||||
Worker(Config *conf = nullptr,
|
Worker(Config *conf = nullptr,
|
||||||
ConfigParser *confParser = nullptr,
|
ConfigParser *confParser = nullptr,
|
||||||
Signer *subscriber = nullptr);
|
Signer *subscriber = nullptr);
|
||||||
~Worker() {
|
~Worker();
|
||||||
delete conf_;
|
|
||||||
delete confParser_;
|
|
||||||
delete subscriber_;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief run It is main method for control of all parsing process.
|
* @brief run It is main method for control of all parsing process.
|
||||||
* @return Returns false if the program terminates with an error.
|
* @return Returns false if the program terminates with an error.
|
||||||
|
|
||||||
*/
|
*/
|
||||||
bool run();
|
bool run();
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user