From cd21a9b1252f4d000b18ccecacc9c4e92d59f67b Mon Sep 17 00:00:00 2001 From: Renaud G Date: Thu, 23 Apr 2015 10:51:01 +0200 Subject: amend files for cli main application --- cli/main.cpp | 122 +++++++++++++++++++++++++++++++++++++++++------------------ 1 file changed, 86 insertions(+), 36 deletions(-) (limited to 'cli') diff --git a/cli/main.cpp b/cli/main.cpp index 7b70e23..8f1ec67 100644 --- a/cli/main.cpp +++ b/cli/main.cpp @@ -19,27 +19,100 @@ * Free Software Foundation, Inc., * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ -#ifdef HAVE_IRC -#include -#include "irc/mainwindow.h" -#endif #include #include "diceparser.h" +#include +#include -int main(int argc, char *argv[]) +void startDiceParsing(QString& cmd,QString& treeFile,bool highlight) { - #ifdef HAVE_IRC - QApplication a(argc, argv); + DiceParser* parser = new DiceParser(); + if(parser->parseLine(cmd)) + { + parser->Start(); + // + if(treeFile.isEmpty()) + { + parser->displayResult(); + } + else + { + parser->writeDownDotTree(); + } + } +} + + - MainWindow main; -#endif - DiceParser* myParser = new DiceParser(); +int main(int argc, char *argv[]) +{ QStringList commands; + QString cmd; + QString dotFile; + + bool color=true; + + QCommandLineParser optionParser; + QCommandLineOption color(QStringList() << "co"<< "color-off", tr("Disable color to highlight result")); + QCommandLineOption version(QStringList() << "v"<< "version", tr("Show the version and quit.")); + QCommandLineOption reset(QStringList() << "reset-settings", tr("Erase the settings and use the default parameters")); + QCommandLineOption dotFile(QStringList() << "d"<<"dot-file", tr("Instead of rolling dice, generate the execution tree and write it in "),"dotfile"); + QCommandLineOption translation(QStringList() << "t"<<"translation", QObject::tr("path to the translation file: "),"translationfile"); + QCommandLineOption help(QStringList() << "h"<<"help", QObject::tr("Display this help")); + + optionParser.addOption(color); + optionParser.addOption(version); + optionParser.addOption(reset); + optionParser.addOption(dotFile); + optionParser.addOption(translation); + optionParser.addOption(help); + + for(int i=1;i6]+@c[=10]" + cmd = commands.first(); + + + startDiceParsing(cmd,dotFile,color); + + /*commands<< "10d10c[>6]+@c[=10]" << "1L[cheminée,chocolat,épée,arc,chute de pierre]" << "10d10c[>=6]-@c[=1]" << "10d10c[>=6]-@c[=1]-@c[=1]" @@ -76,32 +149,9 @@ int main(int argc, char *argv[]) << "la" << "400000D20/400000" << "100*3*8";// +*/ + - if(argc>1) - { - for(int i=1;iparseLine(cmd)) - { - myParser->Start(); - // myParser->displayDotTree(); - myParser->displayResult(); - } - else - { - qDebug() << "echec"; - } - } - #ifdef HAVE_IRC - main.show(); - return a.exec(); -#endif - delete myParser; return 0; } -- cgit v1.2.3-70-g09d2