utility: Headless Coati

switch from qt to boost commandlineoptions
coati can now parse a coatiproject without gui with commandline flag -d
show all commandline options with flag --hidden
This commit is contained in:
Andreas Stallinger
2016-03-07 16:38:53 +01:00
parent b761db9b22
commit fec17e452d
19 changed files with 455 additions and 174 deletions
+2 -3
View File
@@ -6,9 +6,6 @@ add_files(
platform_includes/includesMac.h
platform_includes/includesWindows.h
qt/commandline/QtCommandLineParser.cpp
qt/commandline/QtCommandLineParser.h
qt/element/QtAutocompletionList.cpp
qt/element/QtAutocompletionList.h
qt/element/QtCodeArea.cpp
@@ -148,4 +145,6 @@ add_files(
qt/QtApplication.cpp
qt/QtApplication.h
qt/QtCoreApplication.cpp
qt/QtCoreApplication.h
)
+45
View File
@@ -0,0 +1,45 @@
#include "qt/QtCoreApplication.h"
#include <iostream>
#include "settings/ApplicationSettings.h"
#include "utility/file/FilePath.h"
#include "utility/logging/logging.h"
#include "utility/AppPath.h"
#include "utility/UserPaths.h"
#include "License.h"
QtCoreApplication::QtCoreApplication(int argc, char **argv )
: QCoreApplication(argc, argv)
{
}
QtCoreApplication::~QtCoreApplication()
{
}
void QtCoreApplication::handleMessage(MessageFinishedParsing* message)
{
std::cout << "Finished parsing" << std::endl;
LOG_INFO("Finished parsing");
this->quit();
}
bool QtCoreApplication::saveLicense(License license)
{
if (license.isValid())
{
ApplicationSettings* appSettings = ApplicationSettings::getInstance().get();
std::string appLocation = AppPath::getAppPath();
appSettings->setLicenseString(license.getLicenseEncodedString(appLocation));
FilePath p(appLocation);
appSettings->setLicenseCheck(license.hashLocation(p.absolute().str()));
appSettings->save(UserPaths::getAppSettingsPath());
return true;
}
else
{
LOG_ERROR( "The entered license key is invalid.");
return false;
}
}
+26
View File
@@ -0,0 +1,26 @@
#ifndef QT_COREAPPLICTION_H
#define QT_COREAPPLICTION_H
#include <QCoreApplication>
#include "utility/messaging/MessageListener.h"
#include "utility/messaging/type/MessageFinishedParsing.h"
class License;
class QtCoreApplication
: public QCoreApplication
, public MessageListener<MessageFinishedParsing>
{
public:
QtCoreApplication(int argc, char **argv);
virtual ~QtCoreApplication();
bool saveLicense(License license);
signals:
void quitSignal();
private:
virtual void handleMessage(MessageFinishedParsing* message);
};
#endif // QT_COREAPPLICATION
@@ -1,69 +0,0 @@
#include "qt/commandline/QtCommandLineParser.h"
#include "utility/ConfigManager.h"
#include "utility/messaging/type/MessageLoadProject.h"
#include "utility/messaging/type/MessageStatus.h"
#include "utility/text/TextAccess.h"
QtCommandLineParser::QtCommandLineParser()
{
}
QtCommandLineParser::~QtCommandLineParser()
{
}
void QtCommandLineParser::setup()
{
setApplicationDescription("Coati helper");
addVersionOption();
addHelpOption();
QCommandLineOption projectOption(QStringList() << "p" << "project",
QCoreApplication::translate("main", "Load Coati with the a Coatiprojectfile <CoatiProject>."),
QCoreApplication::translate("main", "CoatiProject"));
addOption(projectOption);
}
void QtCommandLineParser::parseCommandline()
{
if(isSet("project"))
{
QString projectfilename = value("project") ;
FilePath projectfile(projectfilename.toStdString());
bool isValidProjectfile = true;
std::stringstream errorstring("Provided Projectfile is not valid: ");
errorstring << "Provided Projectfile('" << projectfile.fileName() << ") ";
if(!projectfile.exists())
{
errorstring << "does not exist";
isValidProjectfile = false;
}
if(projectfile.extension() != ".coatiproject")
{
errorstring << "has a wrong fileending";
isValidProjectfile = false;
}
std::shared_ptr<ConfigManager> configManager = ConfigManager::createEmpty();
if(!configManager->load(TextAccess::createFromFile(projectfile.str())))
{
errorstring << "could not be loaded";
isValidProjectfile = false;
}
if(isValidProjectfile)
{
MessageLoadProject(projectfile.str(), false).dispatch();
}
else
{
MessageStatus(errorstring.str(), true).dispatch();
LOG_ERROR(errorstring.str());
}
}
}
@@ -1,19 +0,0 @@
#ifndef QTCOMMANDLINEPARSER_H
#define QTCOMMANDLINEPARSER_H
#include <QCommandLineParser>
#include "Application.h"
class QtCommandLineParser : public QCommandLineParser
{
public:
QtCommandLineParser();
~QtCommandLineParser();
void setup();
void parseCommandline();
private:
};
#endif //QTCOMMANDLINEPARSER_H