From bb6b87a2685c0d71b5c38be33c100f85ac0b9cee Mon Sep 17 00:00:00 2001 From: Renaud G Date: Thu, 25 Jul 2019 09:59:29 +0200 Subject: Rework of the component to be a proper lib --- cli/main.cpp | 48 +++++++++++++++++++++++++----------------------- 1 file changed, 25 insertions(+), 23 deletions(-) (limited to 'cli/main.cpp') diff --git a/cli/main.cpp b/cli/main.cpp index d6f6398..958d96f 100644 --- a/cli/main.cpp +++ b/cli/main.cpp @@ -35,6 +35,7 @@ #include #endif +#include "dicealias.h" #include "diceparser.h" #include "displaytoolbox.h" #include "highlightdice.h" @@ -115,7 +116,7 @@ QString diceToMarkdown(QJsonArray array, bool withColor, bool allSameColor, bool } void displayJSon(QString scalarText, QString resultStr, QJsonArray array, bool withColor, QString cmd, QString error, - QString warning, QString comment, bool allSameFaceCount, bool allSameColor) + QString warning, QString comment, bool allSameFaceCount, bool allSameColor) { Q_UNUSED(withColor); QJsonDocument doc; @@ -133,7 +134,7 @@ void displayJSon(QString scalarText, QString resultStr, QJsonArray array, bool w out << doc.toJson() << "\n"; } void displayMarkdown(QString scalarText, QString resultStr, QJsonArray array, bool withColor, QString cmd, - QString error, QString warning, QString comment, bool allSameFaceCount, bool allSameColor) + QString error, QString warning, QString comment, bool allSameFaceCount, bool allSameColor) { Q_UNUSED(withColor); QString str("```Markdown\n"); @@ -165,7 +166,7 @@ void displayMarkdown(QString scalarText, QString resultStr, QJsonArray array, bo out << str; } QString displaySVG(QString scalarText, QString resultStr, QJsonArray array, bool withColor, QString cmd, QString error, - QString warning, QString comment, bool allSameFaceCount, bool allSameColor) + QString warning, QString comment, bool allSameFaceCount, bool allSameColor) { QString str( "\n", "aliasfile"); + "path to alias json files: ", "aliasfile"); QCommandLineOption character(QStringList() << "s" << "charactersheet", - "set Parameters to simulate character sheet: ", "sheetfile"); + "set Parameters to simulate character sheet: ", "sheetfile"); QCommandLineOption markdown(QStringList() << "m" << "markdown", - "The output is formatted in markdown."); + "The output is formatted in markdown."); QCommandLineOption bot(QStringList() << "b" << "bot", - "Discord bot."); + "Discord bot."); QCommandLineOption svg(QStringList() << "g" << "svg", - "The output is formatted in svg."); + "The output is formatted in svg."); QCommandLineOption json(QStringList() << "j" << "json", - "The output is formatted in json."); + "The output is formatted in json."); QCommandLineOption dotFile(QStringList() << "d" << "dot-file", - "Instead of rolling dice, generate the execution tree and write it in ", "dotfile"); + "Instead of rolling dice, generate the execution tree and write it in ", + "dotfile"); QCommandLineOption translation(QStringList() << "t" << "translation", - "path to the translation file: ", "translationfile"); + "path to the translation file: ", "translationfile"); QCommandLineOption help(QStringList() << "h" << "help", - "Display this help"); + "Display this help"); optionParser.addOption(color); optionParser.addOption(version); -- cgit v1.2.3-70-g09d2 From dee4f259c8372dea752ccd222800dfba82372246 Mon Sep 17 00:00:00 2001 From: Renaud G Date: Sun, 28 Jul 2019 01:01:48 +0200 Subject: Clean the memory after execution. --- cli/main.cpp | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'cli/main.cpp') diff --git a/cli/main.cpp b/cli/main.cpp index 958d96f..c597dea 100644 --- a/cli/main.cpp +++ b/cli/main.cpp @@ -367,11 +367,6 @@ int startDiceParsing(QStringList& cmds, QString& treeFile, bool withColor, EXPOR stringResult.replace("\\n", "\n"); stringResult= ParsingToolBox::replaceVariableToValue(stringResult, strLst); - /*for(auto it= strLst.rbegin(); it != strLst.rend(); ++it) - { - stringResult.replace(QStringLiteral("$%1").arg(i), (*it)); - --i; - }*/ int i= strLst.size(); for(auto it= strLst.rbegin(); it != strLst.rend(); ++it) @@ -441,10 +436,12 @@ int startDiceParsing(QStringList& cmds, QString& treeFile, bool withColor, EXPOR } else { + QString error= parser.humanReadableError(); + err << "Error: " << error << "\n"; rt= 1; } } - + parser.cleanAll(); return rt; } #include -- cgit v1.2.3-70-g09d2