implemented program argument handling via boost program options

actorid
Marc Zinnschlag 15 years ago
parent abbdffa0a1
commit f346adb6e1

@ -60,7 +60,7 @@ endif (WIN32)
# Dependencies
find_package(OGRE REQUIRED)
find_package(Boost REQUIRED COMPONENTS system filesystem)
find_package(Boost REQUIRED COMPONENTS system filesystem program_options)
find_package(OIS REQUIRED)
include_directories("."
${OGRE_INCLUDE_DIR} ${OIS_INCLUDE_DIR} ${Boost_INCLUDE_DIR}

@ -1,5 +1,7 @@
#include <iostream>
#include "boost/program_options.hpp"
#include "esm_store/cell_store.hpp"
#include "bsa/bsa_archive.hpp"
#include "ogre/renderer.hpp"
@ -65,9 +67,30 @@ void maintest()
cout << "\nThat's all for now!\n";
}
int main(/*int argc, char**argv*/)
int main(int argc, char**argv)
{
try { maintest(); }
try
{
boost::program_options::options_description desc (
"Syntax: openmw <options>\nAllowed options");
desc.add_options()
("help", "print help message");
boost::program_options::variables_map variables;
boost::program_options::store (
boost::program_options::parse_command_line (argc, argv, desc), variables);
boost::program_options::notify (variables);
if (variables.count ("help"))
{
std::cout << desc << std::endl;
}
else
{
maintest();
}
}
catch(exception &e)
{
cout << "\nERROR: " << e.what() << endl;

Loading…
Cancel
Save