0
0
mirror of https://github.com/mongodb/mongo.git synced 2024-12-01 01:21:03 +01:00

handle errors w/ options, nice helptext for no options

This commit is contained in:
Mike Dirolf 2009-07-09 13:59:28 -04:00
parent 62dad5e7e4
commit d8ce98eb36

View File

@ -506,7 +506,6 @@ int main(int argc, char* argv[], char *envp[] )
bool removeService = false;
bool startService = false;
/* TODO handle exceptions. */
po::variables_map params;
/* don't allow guessing - creates ambiguities when some options are
@ -516,10 +515,16 @@ int main(int argc, char* argv[], char *envp[] )
po::command_line_style::allow_long_disguise ^
po::command_line_style::allow_sticky);
po::store(po::command_line_parser(argc, argv).options(cmdline_options).
positional(positional_options).
style(command_line_style).run(), params);
po::notify(params);
try {
po::store(po::command_line_parser(argc, argv).options(cmdline_options).
positional(positional_options).
style(command_line_style).run(), params);
po::notify(params);
} catch (po::error &e) {
cout << "ERROR: " << e.what() << endl << endl;
cout << visible_options << endl;
return 0;
}
if (params.count("help")) {
cout << visible_options << endl;
@ -694,6 +699,7 @@ int main(int argc, char* argv[], char *envp[] )
dbexit(0);
}
cout << "To run mongod with the default options try 'mongod run'." << endl << endl;
cout << visible_options << endl;
return 0;