forked from mirror/openmw-tes3mp
implemented program argument handling via boost program options
This commit is contained in:
parent
abbdffa0a1
commit
f346adb6e1
2 changed files with 26 additions and 3 deletions
|
@ -60,7 +60,7 @@ endif (WIN32)
|
||||||
# Dependencies
|
# Dependencies
|
||||||
|
|
||||||
find_package(OGRE REQUIRED)
|
find_package(OGRE REQUIRED)
|
||||||
find_package(Boost REQUIRED COMPONENTS system filesystem)
|
find_package(Boost REQUIRED COMPONENTS system filesystem program_options)
|
||||||
find_package(OIS REQUIRED)
|
find_package(OIS REQUIRED)
|
||||||
include_directories("."
|
include_directories("."
|
||||||
${OGRE_INCLUDE_DIR} ${OIS_INCLUDE_DIR} ${Boost_INCLUDE_DIR}
|
${OGRE_INCLUDE_DIR} ${OIS_INCLUDE_DIR} ${Boost_INCLUDE_DIR}
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
|
#include "boost/program_options.hpp"
|
||||||
|
|
||||||
#include "esm_store/cell_store.hpp"
|
#include "esm_store/cell_store.hpp"
|
||||||
#include "bsa/bsa_archive.hpp"
|
#include "bsa/bsa_archive.hpp"
|
||||||
#include "ogre/renderer.hpp"
|
#include "ogre/renderer.hpp"
|
||||||
|
@ -65,9 +67,30 @@ void maintest()
|
||||||
cout << "\nThat's all for now!\n";
|
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)
|
catch(exception &e)
|
||||||
{
|
{
|
||||||
cout << "\nERROR: " << e.what() << endl;
|
cout << "\nERROR: " << e.what() << endl;
|
||||||
|
|
Loading…
Reference in a new issue