summaryrefslogtreecommitdiff
path: root/cpp/src/qpidd.cpp
diff options
context:
space:
mode:
authorKim van der Riet <kpvdr@apache.org>2013-02-28 16:14:30 +0000
committerKim van der Riet <kpvdr@apache.org>2013-02-28 16:14:30 +0000
commit9c73ef7a5ac10acd6a50d5d52bd721fc2faa5919 (patch)
tree2a890e1df09e5b896a9b4168a7b22648f559a1f2 /cpp/src/qpidd.cpp
parent172d9b2a16cfb817bbe632d050acba7e31401cd2 (diff)
downloadqpid-python-asyncstore.tar.gz
Update from trunk r1375509 through r1450773asyncstore
git-svn-id: https://svn.apache.org/repos/asf/qpid/branches/asyncstore@1451244 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/src/qpidd.cpp')
-rw-r--r--cpp/src/qpidd.cpp44
1 files changed, 33 insertions, 11 deletions
diff --git a/cpp/src/qpidd.cpp b/cpp/src/qpidd.cpp
index b5686c6ab8..e17dea3164 100644
--- a/cpp/src/qpidd.cpp
+++ b/cpp/src/qpidd.cpp
@@ -41,6 +41,18 @@ int run_broker(int argc, char *argv[], bool hidden)
{
BootstrapOptions bootOptions(argv[0]);
string defaultPath (bootOptions.module.loadDir);
+
+ // --version causes print and exit
+ if (bootOptions.findArg(argc, argv, "version")) {
+ cout << "qpidd (" << qpid::product << ") version "
+ << qpid::version << endl;
+ return 0;
+ }
+
+ // --help sets a flag so that its presence is known despite
+ // subsequent parse problems.
+ bool helpArgSeen = bootOptions.findArg(argc, argv, "help");
+
// Parse only the common, load, and log options to see which
// modules need to be loaded. Once the modules are loaded,
// the command line will be re-parsed with all of the
@@ -51,32 +63,42 @@ int run_broker(int argc, char *argv[], bool hidden)
bootOptions.log.sinkOptions->detached();
qpid::log::Logger::instance().configure(bootOptions.log);
} catch (const std::exception& e) {
+ if (helpArgSeen) {
+ // provide help even when parsing fails
+ bootOptions.usage();
+ }
// Couldn't configure logging so write the message direct to stderr.
- cerr << "Unexpected error: " << e.what() << endl;
+ cerr << endl << "Unexpected error: " << e.what() << endl;
return 1;
}
for (vector<string>::iterator iter = bootOptions.module.load.begin();
iter != bootOptions.module.load.end();
iter++)
- qpid::tryShlib (iter->data(), false);
+ qpid::tryShlib (*iter);
if (!bootOptions.module.noLoad) {
bool isDefault = defaultPath == bootOptions.module.loadDir;
qpid::loadModuleDir (bootOptions.module.loadDir, isDefault);
}
- // Parse options
- options.reset(new QpiddOptions(argv[0]));
- options->parse(argc, argv, options->common.config);
+ // Parse options. In the second pass, do not allow unknown options.
+ // All the modules have been added now, so any unknown options
+ // should be flagged as errors.
+ try {
+ options.reset(new QpiddOptions(argv[0]));
+ options->parse(argc, argv, options->common.config, false);
+ } catch (const std::exception& /*e*/) {
+ if (helpArgSeen) {
+ // provide help even when parsing fails
+ options->usage();
+ }
+ throw;
+ }
// Options that just print information.
- if (options->common.help || options->common.version) {
- if (options->common.version)
- cout << "qpidd (" << qpid::product << ") version "
- << qpid::version << endl;
- else if (options->common.help)
- options->usage();
+ if (helpArgSeen) {
+ options->usage();
return 0;
}