From 7184bf82c420f79ff794e2c6c405d447176482cc Mon Sep 17 00:00:00 2001 From: Renaud G Date: Sun, 12 Feb 2017 11:04:26 +0100 Subject: -add comment support --- cli/main.cpp | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) (limited to 'cli/main.cpp') diff --git a/cli/main.cpp b/cli/main.cpp index 1b9fdad..462c826 100644 --- a/cli/main.cpp +++ b/cli/main.cpp @@ -117,10 +117,13 @@ QString diceToText(ExportedDiceResult& dice,bool highlight,bool homogeneous) return resultGlobal.join(' '); } -void startDiceParsing(QString& cmd,QString& treeFile,bool highlight) +void startDiceParsing(QStringList& cmds,QString& treeFile,bool highlight) { DiceParser* parser = new DiceParser(); + for(QString cmd : cmds) + { + if(parser->parseLine(cmd)) { // @@ -156,6 +159,10 @@ void startDiceParsing(QString& cmd,QString& treeFile,bool highlight) { str = parser->getStringResult(); } + if(!parser->getComment().isEmpty()) + { + out << "\033[1m" <getComment()<< "\033[0m\n"; + } out << str << "\n"; if(!treeFile.isEmpty()) { @@ -166,6 +173,7 @@ void startDiceParsing(QString& cmd,QString& treeFile,bool highlight) { out << parser->humanReadableError()<< "\n";; } + } } void usage() @@ -261,18 +269,14 @@ int main(int argc, char *argv[]) QStringList cmdList = optionParser.positionalArguments(); // qDebug()<< "rest"<< cmdList; - if(!cmdList.isEmpty()) - { - cmd = cmdList.first(); - } - if(!cmd.isEmpty()) - { - startDiceParsing(cmd,dotFileStr,colorb); + + startDiceParsing(cmdList,dotFileStr,colorb); if(optionParser.isSet(help)) { usage(); } - } + + return 0; } -- cgit v1.2.3-70-g09d2