mirror of
https://github.com/QuasarApp/CopyrightFixer.git
synced 2025-05-07 23:19:43 +00:00
ref #29 Implement method than will parse all input arguments.
This commit is contained in:
parent
65d75dcee9
commit
b52f85e3a3
src
@ -7,45 +7,29 @@
|
||||
|
||||
#include <quasarapp.h>
|
||||
#include <iostream>
|
||||
#include "CopyrighFixer/worker.h"
|
||||
|
||||
void helpCall();
|
||||
using namespace CopyrighFixer;
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
|
||||
Worker *worker = new Worker(new Config,
|
||||
new ConfigParser,
|
||||
new Signer);
|
||||
|
||||
if (!QuasarAppUtils::Params::parseParams(argc, argv)) {
|
||||
helpCall();
|
||||
worker->printHelp();
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (QuasarAppUtils::Params::isEndable("h") || QuasarAppUtils::Params::isEndable("help")) {
|
||||
helpCall();
|
||||
worker->printHelp();
|
||||
return 0;
|
||||
}
|
||||
|
||||
worker->run();
|
||||
|
||||
|
||||
delete worker;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief helpCall - a helper call that display infotmation
|
||||
* about the arguments and how to use them
|
||||
*/
|
||||
void helpCall(){
|
||||
|
||||
QuasarAppUtils::Help::Charters help = {
|
||||
{
|
||||
"Part 0 General", {
|
||||
{"h or help", "These arguments represent a helper call that describes the functionality of each method"},
|
||||
{"-sourceDir path/to/source/dir", "This arrgument sets path to the source directory. By default it is sourceDir = PWD"},
|
||||
{"-sign path/to/sign/file", "This argument sets path to the sign patern. This is a required argument"},
|
||||
{"-currentOwner ownerName", "This argument sets name of the current owner of the code."},
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
help += QuasarAppUtils::Params::getparamsHelp();
|
||||
|
||||
QuasarAppUtils::Params::showHelp(help);
|
||||
|
||||
exit(0);
|
||||
|
||||
}
|
||||
|
@ -10,14 +10,42 @@
|
||||
#include <quasarapp.h>
|
||||
|
||||
|
||||
|
||||
namespace CopyrighFixer {
|
||||
Worker::Worker() {
|
||||
|
||||
Worker::Worker(
|
||||
Config *conf,
|
||||
ConfigParser *confParser,
|
||||
Signer *subscriber) {
|
||||
this->conf_ = conf ?: new Config;
|
||||
this->confParser_ = confParser ?: new ConfigParser;
|
||||
this->subscriber_ = subscriber ?: new Signer;
|
||||
}
|
||||
|
||||
bool Worker::run() {
|
||||
bool Worker::run() const {
|
||||
|
||||
Config currentConfig = this->confParser_->parseOptions(*this->conf_);
|
||||
// this->subscriber_->checkSign()
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
void Worker::printHelp() const {
|
||||
QuasarAppUtils::Help::Charters help = {
|
||||
{
|
||||
"Part 0 General", {
|
||||
{"h or help", "These arguments represent a helper call that describes the functionality of each method"},
|
||||
{"-sourceDir path/to/source/dir", "This arrgument sets path to the source directory. By default it is sourceDir = PWD"},
|
||||
{"-sign path/to/sign/file", "This argument sets path to the sign patern. This is a required argument"},
|
||||
{"-currentOwner ownerName", "This argument sets name of the current owner of the code."},
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
help += QuasarAppUtils::Params::getparamsHelp();
|
||||
|
||||
QuasarAppUtils::Params::showHelp(help);
|
||||
|
||||
exit(0);
|
||||
}
|
||||
|
||||
};
|
||||
|
@ -9,6 +9,9 @@
|
||||
#define WORKER_H
|
||||
|
||||
#include "CopyrighFixer_global.h"
|
||||
#include "config.h"
|
||||
#include "signer.h"
|
||||
#include "configparser.h"
|
||||
|
||||
|
||||
namespace CopyrighFixer {
|
||||
@ -17,15 +20,32 @@ namespace CopyrighFixer {
|
||||
* @brief The Worker class will be control all work process.
|
||||
*/
|
||||
class CopyrighFixer_EXPORT Worker {
|
||||
|
||||
public:
|
||||
Worker();
|
||||
Worker(Config *conf = nullptr,
|
||||
ConfigParser *confParser = nullptr,
|
||||
Signer *subscriber = nullptr);
|
||||
~Worker() {
|
||||
delete conf_;
|
||||
delete confParser_;
|
||||
delete subscriber_;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief run It is main method for control of all parsing process.
|
||||
* @return
|
||||
*/
|
||||
bool run();
|
||||
bool run() const;
|
||||
|
||||
/**
|
||||
* @brief printHelp Display infotmation about the arguments and how to use them.
|
||||
*/
|
||||
void printHelp() const;
|
||||
|
||||
protected:
|
||||
Config *conf_;
|
||||
ConfigParser *confParser_;
|
||||
Signer *subscriber_;
|
||||
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user