From 7a5bc0677e5e7f6d72fb4432672bc309f7ff61da Mon Sep 17 00:00:00 2001 From: Renaud G Date: Sat, 14 Jan 2017 22:39:04 +0100 Subject: -fix help command. --- cli/main.cpp | 2 +- diceparser.cpp | 5 ++++- parsingtoolbox.cpp | 3 ++- webserver/diceserver.cpp | 10 +++++++++- 4 files changed, 16 insertions(+), 4 deletions(-) diff --git a/cli/main.cpp b/cli/main.cpp index 7a5ed97..1b9fdad 100644 --- a/cli/main.cpp +++ b/cli/main.cpp @@ -268,7 +268,7 @@ int main(int argc, char *argv[]) if(!cmd.isEmpty()) { startDiceParsing(cmd,dotFileStr,colorb); - if(cmd=="help") + if(optionParser.isSet(help)) { usage(); } diff --git a/diceparser.cpp b/diceparser.cpp index e71a24c..f2e3104 100644 --- a/diceparser.cpp +++ b/diceparser.cpp @@ -682,7 +682,10 @@ bool DiceParser::readCommand(QString& str,ExecutionNode* & node) if(str== QLatin1String("help")) { HelpNode* help = new HelpNode(); - help->setHelpPath(m_helpPath); + if(!m_helpPath.isEmpty()) + { + help->setHelpPath(m_helpPath); + } node = help; } diff --git a/parsingtoolbox.cpp b/parsingtoolbox.cpp index 8bd52b7..1d5e7ef 100644 --- a/parsingtoolbox.cpp +++ b/parsingtoolbox.cpp @@ -334,7 +334,6 @@ bool ParsingToolBox::readString(QString &str, QString& strResult) if(str.startsWith('"')) { str=str.remove(0,1); - } int i=0; int j=0; @@ -373,6 +372,8 @@ bool ParsingToolBox::readString(QString &str, QString& strResult) return true; } } + } + return false; } diff --git a/webserver/diceserver.cpp b/webserver/diceserver.cpp index 7332f81..c1e1ca0 100644 --- a/webserver/diceserver.cpp +++ b/webserver/diceserver.cpp @@ -9,6 +9,8 @@ DiceServer::DiceServer(int port) : QObject(),m_diceParser(new DiceParser()) { + + m_diceParser->setPathToHelp("Documentation"); // using namespace ; m_server = new qhttp::server::QHttpServer(this); m_server->listen( // listening on 0.0.0.0:8080 @@ -36,15 +38,21 @@ DiceServer::DiceServer(int port) { qDebug() << QUrl::fromPercentEncoding(m_hashArgs["cmd"].toLocal8Bit()); QString result = startDiceParsing(QUrl::fromPercentEncoding(m_hashArgs["cmd"].toLocal8Bit())); + qDebug() << result; res->setStatusCode(qhttp::ESTATUS_OK); + res->addHeader("Access-Control-Allow-Origin", "*"); + res->addHeader("Access-Control-Allow-Methods", "POST, GET, OPTIONS"); + res->addHeader("Access-Control-Allow-Headers", "x-requested-with"); + + QString html("\n" "\n" "\n" - "\n" " \n" " Rolisteam Dice System Webservice\n" " " + "\n" "\n" "%1\n" "\n" -- cgit v1.2.3-70-g09d2