diff --git a/src/Makefile b/src/Makefile index da1f4ec..b4feba6 100644 --- a/src/Makefile +++ b/src/Makefile @@ -1,7 +1,7 @@ #This is the makefile USEDBIXX=1 -BASE_LIBS=-lgcrypt +BASE_LIBS=-lgcrypt -lboost_program_options BASE_CFLAGS=-c -g -O2 -Wall O_FILES=build/oastat.o build/oastatstruct.o build/kill2db.o build/init2db.o build/shutdown2db.o build/userinfo2db.o build/disconnect2db.o build/award2db.o build/ctf2db.o build/point2db.o build/ctf1f2db.o build/elimination2db.o build/ctfelim2db.o build/harvester2db.o build/challenge2db.o build/warmup2db.o build/accuracy2db.o diff --git a/src/oastat.cpp b/src/oastat.cpp index ceb42ee..36943fc 100644 --- a/src/oastat.cpp +++ b/src/oastat.cpp @@ -31,6 +31,7 @@ http://code.google.com/p/oastat/ #include #include #include +#include using namespace std; @@ -157,7 +158,7 @@ static int processStdIn(istream &in_p,vector > &commands) */ osslist.clear(); cerr << "oastat: Crashed (NEAR FATAL EXCEPTION) at line: \"" << line << "\"" << endl << - "oastat: Error is: " << e2.what() << endl; + "oastat: Error is: " << e2.what() << endl; done = false; } } while (!done); @@ -204,27 +205,44 @@ int main (int argc, const char* argv[]) f % getenv("HOME"); filename = f.str(); //////////// - for (int i=1; i(), "The DB backend to use") + ("dbargs", boost::program_options::value(), "Arguments passed to the DB backend") + ("filename,f", boost::program_options::value(), "Filename to read. Providing a blank string will read from stdin") + ("tail", "Use tail on the filename given to read the file") + ("integration-test", "Perform integration test") + ; + boost::program_options::variables_map vm; + boost::program_options::store(boost::program_options::parse_command_line(argc, argv, desc), vm); + boost::program_options::notify(vm); + if (vm.count("help")) { + cout << desc << endl; + cout << "Examples: " << endl; + cout << argv[0] << " -f \"~/.openarena/baseoa/games.log\" --backend \"DbiXX\" --dbarg \"mysql dbname oastat username openarena\"" << endl; + cout << argv[0] << " -f \"~/.openarena/baseoa/games.log\" --backend \"DbiXX\" --dbarg \"pgsql dbname oastat username openarena\"" << endl; + cout << "tail -f \"~/.openarena/baseoa/games.log\" | "<< argv[0] << " -f \"\" --backend \"Xml\" --dbarg \"outputdir ~/oastat\"" << endl; + cout << endl; + cout << "Look at http://code.google.com/p/oastat for more help and more details" << endl; + return 1; + } + if (vm.count("backend")) { + backend = vm["backend"].as(); } + if (vm.count("dbargs")) { + dbargs = vm["dbargs"].as(); + } + if (vm.count("filename")) { + filename = vm["filename"].as(); + } + if (vm.count("tail")) { + useTail = true; + } + if (vm.count("integration-test")) { + doIntegrationTest = true; + } + try { shared_ptr db;