diff options
| author | 2017-02-12 11:04:26 +0100 | |
|---|---|---|
| committer | 2017-02-12 11:04:26 +0100 | |
| commit | 7184bf82c420f79ff794e2c6c405d447176482cc (patch) | |
| tree | 1ba89413c16c6fa91e66b77dfd87993fa96cb53a /cli | |
| parent | 3fcdcc21088fb99eb6f7206618909940314e7472 (diff) | |
| download | OneRoll-7184bf82c420f79ff794e2c6c405d447176482cc.tar.gz OneRoll-7184bf82c420f79ff794e2c6c405d447176482cc.zip | |
-add comment support
Diffstat (limited to 'cli')
| -rw-r--r-- | cli/main.cpp | 22 |
1 files changed, 13 insertions, 9 deletions
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" <<parser->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; } |