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 | 891d06f45401fc051dc7641f8a3e0c20d1f49adb (patch) | |
tree | 8628b3e62109cf8e0276582cf85fe32fe1b84598 /qpid/cpp/src/qpidd.cpp | |
parent | f0bd680fa1ddc75ed7446a5b1ac1d041a5c3eff8 (diff) | |
download | qpid-python-891d06f45401fc051dc7641f8a3e0c20d1f49adb.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@532491 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/cpp/src/qpidd.cpp')
-rw-r--r-- | qpid/cpp/src/qpidd.cpp | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/qpid/cpp/src/qpidd.cpp b/qpid/cpp/src/qpidd.cpp index 8825f67233..d77b472ead 100644 --- a/qpid/cpp/src/qpidd.cpp +++ b/qpid/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; } |