mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-29 22:45:34 +00:00
Refactor tools to do not use boost exceptions and exit() command
This commit is contained in:
parent
059a8fd32a
commit
68c170f065
2 changed files with 10 additions and 22 deletions
|
@ -123,14 +123,9 @@ bool parseOptions (int argc, char** argv, Arguments &info)
|
|||
|
||||
bpo::store(valid_opts, variables);
|
||||
}
|
||||
catch(boost::program_options::unknown_option & x)
|
||||
catch(std::exception &e)
|
||||
{
|
||||
std::cerr << "ERROR: " << x.what() << std::endl;
|
||||
return false;
|
||||
}
|
||||
catch(boost::program_options::invalid_command_line_syntax & x)
|
||||
{
|
||||
std::cerr << "ERROR: " << x.what() << std::endl;
|
||||
std::cout << "ERROR parsing arguments: " << e.what() << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
#include <components/vfs/bsaarchive.hpp>
|
||||
#include <components/vfs/filesystemarchive.hpp>
|
||||
|
||||
#include <boost/exception/all.hpp>
|
||||
#include <boost/program_options.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"
|
||||
"Usages:\n"
|
||||
|
@ -108,37 +107,31 @@ std::vector<std::string> parseOptions (int argc, char** argv)
|
|||
{
|
||||
std::cout << "ERROR parsing arguments: " << e.what() << "\n\n"
|
||||
<< desc << std::endl;
|
||||
exit(1);
|
||||
return false;
|
||||
}
|
||||
|
||||
bpo::notify(variables);
|
||||
if (variables.count ("help"))
|
||||
{
|
||||
std::cout << desc << std::endl;
|
||||
exit(1);
|
||||
return false;
|
||||
}
|
||||
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 << desc << std::endl;
|
||||
exit(1);
|
||||
return false;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
std::vector<std::string> files;
|
||||
try
|
||||
{
|
||||
files = parseOptions (argc, argv);
|
||||
}
|
||||
catch( boost::exception &e )
|
||||
{
|
||||
std::cout << "ERROR parsing arguments: " << boost::diagnostic_information(e) << std::endl;
|
||||
exit(1);
|
||||
}
|
||||
if(!parseOptions (argc, argv, files))
|
||||
return 1;
|
||||
|
||||
// std::cout << "Reading Files" << std::endl;
|
||||
for(std::vector<std::string>::const_iterator it=files.begin(); it!=files.end(); ++it)
|
||||
|
|
Loading…
Reference in a new issue