diff options
author | Alan Conway <aconway@apache.org> | 2007-04-25 21:26:53 +0000 |
---|---|---|
committer | Alan Conway <aconway@apache.org> | 2007-04-25 21:26:53 +0000 |
commit | d0cfa8d4724bd5f5f018d923d62d9bea87cdcb80 (patch) | |
tree | 4bc00d56b87042316db72b7bc3bb65df6a37ff76 /cpp/src/qpidd.cpp | |
parent | aefcbcdd3f930f4934b022df6b214d6a62f81d35 (diff) | |
download | qpid-python-d0cfa8d4724bd5f5f018d923d62d9bea87cdcb80.tar.gz |
Added environment variables as a source of Qpid configuration.
Option "foo-bar" will be read from env. QPID_FOO_BAR if
not specified on command line.
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@532491 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/src/qpidd.cpp')
-rw-r--r-- | cpp/src/qpidd.cpp | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/cpp/src/qpidd.cpp b/cpp/src/qpidd.cpp index 8825f67233..d77b472ead 100644 --- a/cpp/src/qpidd.cpp +++ b/cpp/src/qpidd.cpp @@ -54,18 +54,27 @@ struct QpiddOptions : public Broker::Options void parse(int argc, char* argv[]) { po::variables_map vm; + // Earlier sources get precedence. po::store(po::parse_command_line(argc, argv, desc), vm); + try { + po::store(po::parse_environment(desc, po::env2option), vm); + } + catch (const logic_error& e) { + // Make it clear this is an env. var problem, the + // exception from boost::program_options doesn't. + throw logic_error(string(e.what())+" (parsing environment variables)"); + } po::notify(vm); }; - void usage(std::ostream& out) const { + void usage(ostream& out) const { out << "Usage: qpidd [OPTIONS]" << endl << "Start the Qpid AMQP broker." << endl << endl << desc << endl; }; }; -std::ostream& operator<<(std::ostream& out, const QpiddOptions& config) { +ostream& operator<<(ostream& out, const QpiddOptions& config) { config.usage(out); return out; } |