summaryrefslogtreecommitdiff
path: root/cpp/src
diff options
context:
space:
mode:
authorGordon Sim <gsim@apache.org>2006-12-06 08:11:57 +0000
committerGordon Sim <gsim@apache.org>2006-12-06 08:11:57 +0000
commit905c59a988010c9db7f64ee90f9d0b6e1011f0d0 (patch)
tree60bfef5035aea1284d1d216de2c57ebd8ba9063f /cpp/src
parent7ece6a3212f401f5ce298e01728f939e670dc4d9 (diff)
downloadqpid-python-905c59a988010c9db7f64ee90f9d0b6e1011f0d0.tar.gz
Patch sumbitted to qpid-dev:
2006-12-05 Jim Meyering <meyering@redhat.com> Improve --help output. Add --version option. * lib/broker/Configuration.cpp: Include <config.h>. (Configuration::Configuration): Use the active voice. Handle --version. (Configuration::usage): Add Usage:... and bug-reporting address. Output short+long options like "-o, --option ...", so that help2man will format them properly. * lib/broker/Configuration.h: (class Configuration) [version, programName]: New members. (parse): Update prototype. (isVersion, setValue): New prototypes. * src/qpidd.cpp: Include <config.h>. (programName): New file-scoped global. (handle_signal, main): Emit diagnostics to stderr. (main): Pass program name to config.parse. (main): Handle new --version option. Also updated ConfigurationTest to use the modified parse() method. git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@482958 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/src')
-rw-r--r--cpp/src/qpidd.cpp16
1 files changed, 11 insertions, 5 deletions
diff --git a/cpp/src/qpidd.cpp b/cpp/src/qpidd.cpp
index 0cfa3207ff..8285f1aefb 100644
--- a/cpp/src/qpidd.cpp
+++ b/cpp/src/qpidd.cpp
@@ -7,9 +7,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -23,6 +23,9 @@
#include <signal.h>
#include <iostream>
#include <memory>
+#include <config.h>
+
+static char const* programName = "qpidd";
using namespace qpid::broker;
using namespace qpid::sys;
@@ -30,7 +33,7 @@ using namespace qpid::sys;
Broker::shared_ptr broker;
void handle_signal(int /*signal*/){
- std::cout << "Shutting down..." << std::endl;
+ std::cerr << "Shutting down..." << std::endl;
broker->shutdown();
}
@@ -38,9 +41,12 @@ int main(int argc, char** argv)
{
Configuration config;
try {
- config.parse(argc, argv);
+ config.parse(programName, argc, argv);
if(config.isHelp()){
config.usage();
+ }else if(config.isVersion()){
+ std::cout << programName << " (" << PACKAGE_NAME << ") version "
+ << PACKAGE_VERSION << std::endl;
}else{
broker = Broker::create(config);
signal(SIGINT, handle_signal);
@@ -48,7 +54,7 @@ int main(int argc, char** argv)
}
return 0;
} catch(const std::exception& e) {
- std::cout << e.what() << std::endl;
+ std::cerr << e.what() << std::endl;
}
return 1;
}