mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-03-25 16:43:33 +00:00
Refactor tools to do not use boost exceptions and exit() command
This commit is contained in:
parent
059a8fd32a
commit
68c170f065
@ -123,14 +123,9 @@ bool parseOptions (int argc, char** argv, Arguments &info)
|
|||||||
|
|
||||||
bpo::store(valid_opts, variables);
|
bpo::store(valid_opts, variables);
|
||||||
}
|
}
|
||||||
catch(boost::program_options::unknown_option & x)
|
catch(std::exception &e)
|
||||||
{
|
{
|
||||||
std::cerr << "ERROR: " << x.what() << std::endl;
|
std::cout << "ERROR parsing arguments: " << e.what() << std::endl;
|
||||||
return false;
|
|
||||||
}
|
|
||||||
catch(boost::program_options::invalid_command_line_syntax & x)
|
|
||||||
{
|
|
||||||
std::cerr << "ERROR: " << x.what() << std::endl;
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10,7 +10,6 @@
|
|||||||
#include <components/vfs/bsaarchive.hpp>
|
#include <components/vfs/bsaarchive.hpp>
|
||||||
#include <components/vfs/filesystemarchive.hpp>
|
#include <components/vfs/filesystemarchive.hpp>
|
||||||
|
|
||||||
#include <boost/exception/all.hpp>
|
|
||||||
#include <boost/program_options.hpp>
|
#include <boost/program_options.hpp>
|
||||||
#include <boost/filesystem.hpp>
|
#include <boost/filesystem.hpp>
|
||||||
|
|
||||||
@ -81,7 +80,7 @@ void readVFS(VFS::Archive* anArchive,std::string archivePath = "")
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<std::string> parseOptions (int argc, char** argv)
|
bool parseOptions (int argc, char** argv, std::vector<std::string>& files)
|
||||||
{
|
{
|
||||||
bpo::options_description desc("Ensure that OpenMW can use the provided NIF and BSA files\n\n"
|
bpo::options_description desc("Ensure that OpenMW can use the provided NIF and BSA files\n\n"
|
||||||
"Usages:\n"
|
"Usages:\n"
|
||||||
@ -108,37 +107,31 @@ std::vector<std::string> parseOptions (int argc, char** argv)
|
|||||||
{
|
{
|
||||||
std::cout << "ERROR parsing arguments: " << e.what() << "\n\n"
|
std::cout << "ERROR parsing arguments: " << e.what() << "\n\n"
|
||||||
<< desc << std::endl;
|
<< desc << std::endl;
|
||||||
exit(1);
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bpo::notify(variables);
|
bpo::notify(variables);
|
||||||
if (variables.count ("help"))
|
if (variables.count ("help"))
|
||||||
{
|
{
|
||||||
std::cout << desc << std::endl;
|
std::cout << desc << std::endl;
|
||||||
exit(1);
|
return false;
|
||||||
}
|
}
|
||||||
if (variables.count("input-file"))
|
if (variables.count("input-file"))
|
||||||
{
|
{
|
||||||
return variables["input-file"].as< std::vector<std::string> >();
|
files = variables["input-file"].as< std::vector<std::string> >();
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::cout << "No input files or directories specified!" << std::endl;
|
std::cout << "No input files or directories specified!" << std::endl;
|
||||||
std::cout << desc << std::endl;
|
std::cout << desc << std::endl;
|
||||||
exit(1);
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
std::vector<std::string> files;
|
std::vector<std::string> files;
|
||||||
try
|
if(!parseOptions (argc, argv, files))
|
||||||
{
|
return 1;
|
||||||
files = parseOptions (argc, argv);
|
|
||||||
}
|
|
||||||
catch( boost::exception &e )
|
|
||||||
{
|
|
||||||
std::cout << "ERROR parsing arguments: " << boost::diagnostic_information(e) << std::endl;
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
// std::cout << "Reading Files" << std::endl;
|
// std::cout << "Reading Files" << std::endl;
|
||||||
for(std::vector<std::string>::const_iterator it=files.begin(); it!=files.end(); ++it)
|
for(std::vector<std::string>::const_iterator it=files.begin(); it!=files.end(); ++it)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user