diff options
| author | 2015-05-02 12:01:19 +0200 | |
|---|---|---|
| committer | 2015-05-02 12:01:19 +0200 | |
| commit | 479b96210a01c152d5498e97cd66c47258918c49 (patch) | |
| tree | 0cb099c56e2000240d113581b05d11d7898b9b02 /cli/main.cpp | |
| parent | e1429844d3c7c2feeec8291084fb7f36e9ef38af (diff) | |
| download | OneRoll-479b96210a01c152d5498e97cd66c47258918c49.tar.gz OneRoll-479b96210a01c152d5498e97cd66c47258918c49.zip | |
-Add gpl header or/and add class description for doxygen.
Diffstat (limited to 'cli/main.cpp')
| -rw-r--r-- | cli/main.cpp | 46 |
1 files changed, 36 insertions, 10 deletions
diff --git a/cli/main.cpp b/cli/main.cpp index 94fcc00..2c4ddfa 100644 --- a/cli/main.cpp +++ b/cli/main.cpp @@ -24,7 +24,10 @@ #include "diceparser.h" #include <QCommandLineParser> #include <QCommandLineOption> -#include <QDebug> +#include <QTextStream> + + +QTextStream out(stdout, QIODevice::WriteOnly); QString diceToText(ExportedDiceResult& dice) { @@ -93,7 +96,7 @@ void startDiceParsing(QString& cmd,QString& treeFile,bool highlight) parser->Start(); if(!parser->getErrorMap().isEmpty()) { - qDebug() << "Error" << parser->humanReadableError(); + out << "Error" << parser->humanReadableError()<< "\n"; return; } @@ -116,9 +119,9 @@ void startDiceParsing(QString& cmd,QString& treeFile,bool highlight) if(parser->hasStringResult()) { - str = parser->getStringResult().replace("\n","<br/>"); + str = parser->getStringResult(); } - qDebug() << str; + out << str << "\n"; } else { @@ -127,18 +130,35 @@ void startDiceParsing(QString& cmd,QString& treeFile,bool highlight) } else { - qDebug() << parser->humanReadableError(); + out << parser->humanReadableError()<< "\n";; } } - +void usage() +{ + QString help = "Usage: ./dice [options]\n\ +\n\ +Options:\n\ + -c, --color-off Disable color to highlight result\n\ + -v, --version Show the version and quit.\n\ + --reset-settings Erase the settings and use the default\n\ + parameters\n\ + -d, --dot-file <dotfile> Instead of rolling dice, generate the\n\ + execution tree and write it in <dotfile>\n\ + -t, --translation <translationfile> path to the translation file:\n\ + <translationfile>\n\ + -h, --help Display this help\n\ +"; + + out << help; +} int main(int argc, char *argv[]) { - //QCoreApplication app(argc,argv); - //QCoreApplication::setApplicationName("dice"); - //QCoreApplication::setApplicationVersion("1.0"); + QCoreApplication app(argc,argv); + QCoreApplication::setApplicationName("dice"); + QCoreApplication::setApplicationVersion("1.0"); QStringList commands; @@ -157,7 +177,7 @@ int main(int argc, char *argv[]) if(!optionParser.addOption(color)) { - qDebug()<< optionParser.errorText(); + out << optionParser.errorText() << "\n"; } optionParser.addOption(version); @@ -184,6 +204,8 @@ int main(int argc, char *argv[]) } else if(optionParser.isSet(version)) { + out << "Rolisteam DiceParser v1.0.0"<< "\n"; + out << "More Details: www.rolisteam.org"<< "\n"; return 0; } else if(optionParser.isSet(reset)) @@ -212,6 +234,10 @@ int main(int argc, char *argv[]) if(!cmd.isEmpty()) { startDiceParsing(cmd,dotFileStr,colorb); + if(cmd=="help") + { + usage(); + } } /*commands<< "10d10c[>6]+@c[=10]" |