Allow setting config file options also from command line
This commit is contained in:
parent
bb8e202db9
commit
47f86754ea
4 changed files with 12 additions and 5 deletions
|
@ -50,7 +50,7 @@ typedef boost::program_options::variables_map Variables;
|
|||
class Config {
|
||||
public:
|
||||
/// Constructor.
|
||||
Config() {}
|
||||
Config(int argc = 0, char **argv = NULL) : m_argc(argc), m_argv(argv) {}
|
||||
|
||||
/// Destructor
|
||||
virtual ~Config() {}
|
||||
|
@ -99,6 +99,8 @@ class Config {
|
|||
boost::signal<void ()> onConfigReloaded;
|
||||
|
||||
private:
|
||||
int m_argc;
|
||||
char **m_argv;
|
||||
Variables m_variables;
|
||||
std::map<std::string, std::string> m_unregistered;
|
||||
std::string m_file;
|
||||
|
|
|
@ -114,7 +114,7 @@ static void daemonize(const char *cwd, const char *lock_file) {
|
|||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
Config config;
|
||||
Config config(argc, argv);
|
||||
|
||||
boost::program_options::variables_map vm;
|
||||
bool no_daemon = false;
|
||||
|
|
|
@ -8,13 +8,13 @@ backend_host=localhost
|
|||
pidfile=./test.pid
|
||||
# < this option doesn't work yet
|
||||
#backend_port=10001
|
||||
admin_jid=admin@localhost
|
||||
#admin_jid=admin@localhost
|
||||
admin_password=test
|
||||
#cert=server.pfx #patch to PKCS#12 certificate
|
||||
#cert_password=test #password to that certificate if any
|
||||
users_per_backend=10
|
||||
#backend=../..//backends/libpurple/spectrum2_libpurple_backend
|
||||
backend=../../backends/template/template_backend.py
|
||||
backend=../..//backends/libpurple/spectrum2_libpurple_backend
|
||||
#backend=../../backends/template/template_backend.py
|
||||
protocol=prpl-jabber
|
||||
#protocol=prpl-msn
|
||||
#protocol=any
|
||||
|
|
|
@ -187,6 +187,11 @@ bool Config::load(std::istream &ifs, boost::program_options::options_description
|
|||
}
|
||||
}
|
||||
|
||||
// Load configs passed by command line
|
||||
if (m_argc != 0 && m_argv) {
|
||||
store(parse_command_line(m_argc, m_argv, opts), m_variables);
|
||||
}
|
||||
|
||||
store(parsed, m_variables);
|
||||
notify(m_variables);
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue