# HG changeset patch # User Waqas Hussain # Date 1292155824 -18000 # Node ID f3216c4a34e86870330bd08dcf213d67901e134f # Parent b76ac6c3a037cb0a67a57272e67d4e6f08889891 prosodyctl: Added support for --config command line argument, and multiple config parsers (to match the main prosody executable). diff -r b76ac6c3a037 -r f3216c4a34e8 prosodyctl --- a/prosodyctl Sun Dec 12 15:42:00 2010 +0500 +++ b/prosodyctl Sun Dec 12 17:10:24 2010 +0500 @@ -40,9 +40,30 @@ config = require "core.configmanager" do - -- TODO: Check for other formats when we add support for them - -- Use lfs? Make a new conf/ dir? - local ok, level, err = config.load((CFG_CONFIGDIR or ".").."/prosody.cfg.lua"); + local filenames = {}; + + local filename; + if arg[1] == "--config" and arg[2] then + table.insert(filenames, arg[2]); + table.remove(arg, 1); table.remove(arg, 1); + if CFG_CONFIGDIR then + table.insert(filenames, CFG_CONFIGDIR.."/"..arg[2]); + end + else + for _, format in ipairs(config.parsers()) do + table.insert(filenames, (CFG_CONFIGDIR or ".").."/prosody.cfg."..format); + end + end + for _,_filename in ipairs(filenames) do + filename = _filename; + local file = io.open(filename); + if file then + file:close(); + CFG_CONFIGDIR = filename:match("^(.*)[\\/][^\\/]*$"); + break; + end + end + local ok, level, err = config.load(filename); if not ok then print("\n"); print("**************************");