From 479b96210a01c152d5498e97cd66c47258918c49 Mon Sep 17 00:00:00 2001 From: Renaud G Date: Sat, 2 May 2015 12:01:19 +0200 Subject: -Add gpl header or/and add class description for doxygen. --- cli/main.cpp | 46 ++++++++++++++++++++++++++++++++++++---------- 1 file changed, 36 insertions(+), 10 deletions(-) (limited to 'cli/main.cpp') 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 #include -#include +#include + + +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","
"); + 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 Instead of rolling dice, generate the\n\ + execution tree and write it in \n\ + -t, --translation path to the translation file:\n\ + \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]" -- cgit v1.2.3-70-g09d2 From 6dbf254b7d5b19b77eb4716b24a1768f48b11248 Mon Sep 17 00:00:00 2001 From: Renaud G Date: Sun, 3 May 2015 02:53:34 +0200 Subject: -Add install target to make file. -Add comments and class descriptions. --- CMakeLists.txt | 47 +++++++++++++++++++---------------------------- cli/main.cpp | 18 ++++++++++++++++-- dicealias.h | 2 +- diceparser.h | 11 ----------- die.h | 2 +- result/stringresult.h | 2 +- 6 files changed, 38 insertions(+), 44 deletions(-) (limited to 'cli/main.cpp') diff --git a/CMakeLists.txt b/CMakeLists.txt index b654ea2..e8b4c5c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,11 +3,6 @@ cmake_minimum_required(VERSION 2.8) project(dice) -#/net/rnd/src/qt/qt-everywhere-enterprise-src-5.3.0/linux-x86_64-gcc-4.7.2/lib/cmake -#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -#${Qt5Widgets_EXECUTABLE_COMPILE_FLAGS}") - - # Find includes in corresponding build directories set(CMAKE_INCLUDE_CURRENT_DIR ON) # Instruct CMake to run moc automatically when needed. @@ -15,20 +10,15 @@ set(CMAKE_AUTOMOC ON) # Find the QtWidgets library find_package(Qt5Core) - set(EXECUTABLE_OUTPUT_PATH bin/) + include_directories(${Qt5Core_INCLUDES}) add_definitions(${Qt5Core_DEFINITIONS}) set(MODE "cli") -#file ( -# GLOB_RECURSE -# source_files -# *.cpp -# result/* -# node/* -#) + + add_executable( dice diceparser.cpp @@ -43,27 +33,28 @@ add_executable( result/stringresult.cpp result/diceresult.cpp node/countexecutenode.cpp -node/dicerollernode.cpp -node/executionnode.cpp -node/explosedicenode.cpp -node/helpnode.cpp -node/jumpbackwardnode.cpp -node/keepdiceexecnode.cpp -node/listaliasnode.cpp -node/listsetrollnode.cpp -node/numbernode.cpp -node/parenthesesnode.cpp -node/rerolldicenode.cpp -node/scalaroperatornode.cpp -node/sortresult.cpp -node/startingnode.cpp -cli/main.cpp + node/dicerollernode.cpp + node/executionnode.cpp + node/explosedicenode.cpp + node/helpnode.cpp + node/jumpbackwardnode.cpp + node/keepdiceexecnode.cpp + node/listaliasnode.cpp + node/listsetrollnode.cpp + node/numbernode.cpp + node/parenthesesnode.cpp + node/rerolldicenode.cpp + node/scalaroperatornode.cpp + node/sortresult.cpp + node/startingnode.cpp + cli/main.cpp ) #add_executable(dice cli/main.cpp) target_link_libraries(dice ${Qt5Core_LIBRARIES}) +INSTALL_TARGETS(/bin dice) #qt5_use_modules() diff --git a/cli/main.cpp b/cli/main.cpp index 2c4ddfa..f005cc3 100644 --- a/cli/main.cpp +++ b/cli/main.cpp @@ -26,6 +26,20 @@ #include #include +/** + * @page Dice + * The cli for DiceParser the new dice system from rolisteam. + * @section Build and install + * To build this program, type these command: + * - mkdir build + * - cd build + * - cmake ../ + * - make + * - make install + * @return + */ + + QTextStream out(stdout, QIODevice::WriteOnly); @@ -156,9 +170,9 @@ Options:\n\ int main(int argc, char *argv[]) { - QCoreApplication app(argc,argv); + /*QCoreApplication app(argc,argv); QCoreApplication::setApplicationName("dice"); - QCoreApplication::setApplicationVersion("1.0"); + QCoreApplication::setApplicationVersion("1.0");*/ QStringList commands; diff --git a/dicealias.h b/dicealias.h index ebf7a02..5acca46 100644 --- a/dicealias.h +++ b/dicealias.h @@ -24,7 +24,7 @@ #include /** - * @brief The DiceAlias class + * @brief The DiceAlias class is dedicated to store aliases, alias is mainly two QString. The Alias and its replacement. The replacement can be a simple QString or a RegExp. */ class DiceAlias { diff --git a/diceparser.h b/diceparser.h index 717630e..17f8e1c 100644 --- a/diceparser.h +++ b/diceparser.h @@ -58,7 +58,6 @@ class ExploseDiceNode; * */ -class Dice; /** * @brief The DiceParser class facade class, it receives a command and return a DiceResult class (not yet implemented). */ @@ -293,14 +292,4 @@ private: ParsingToolBox* m_parsingToolbox; }; -/** - * @brief The Dice class is a basic class to store dice. (May not be required any more). - */ -class Dice -{ -public: - DiceParser::DiceOperator m_diceOp; - int m_faces; -}; - #endif // DICEPARSER_H diff --git a/die.h b/die.h index c9ed28a..6b640b7 100644 --- a/die.h +++ b/die.h @@ -25,7 +25,7 @@ #include /** - * @brief The Die class + * @brief The Die class implements all methods required from a die. You must set the Faces first, then you can roll it and roll it again, to add or replace the previous result. */ class Die { diff --git a/result/stringresult.h b/result/stringresult.h index 4a9a4a4..5a6b26c 100644 --- a/result/stringresult.h +++ b/result/stringresult.h @@ -4,7 +4,7 @@ #include #include "result.h" /** - * @brief The StringResult class + * @brief The StringResult class stores command result for String. */ class StringResult : public Result { -- cgit v1.2.3-70-g09d2