diff --git a/apps/esmtool/esmtool.cpp b/apps/esmtool/esmtool.cpp index d4569000bf..699ff855c5 100644 --- a/apps/esmtool/esmtool.cpp +++ b/apps/esmtool/esmtool.cpp @@ -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; } diff --git a/apps/niftest/niftest.cpp b/apps/niftest/niftest.cpp index 6c0c745972..e3f2b89f8b 100644 --- a/apps/niftest/niftest.cpp +++ b/apps/niftest/niftest.cpp @@ -10,7 +10,6 @@ #include #include -#include #include #include @@ -81,7 +80,7 @@ void readVFS(VFS::Archive* anArchive,std::string archivePath = "") } } -std::vector parseOptions (int argc, char** argv) +bool parseOptions (int argc, char** argv, std::vector& 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 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 >(); + files = variables["input-file"].as< std::vector >(); + 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 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::const_iterator it=files.begin(); it!=files.end(); ++it)