main: Accept the config file from the cli

This commit is contained in:
PapaTutuWawa 2021-11-25 22:31:03 +01:00
parent 40fcd404a4
commit 8ab23c63ab

View File

@ -489,21 +489,26 @@ class BridgeComponent(ComponentXMPP):
asyncio.ensure_future(self._discord.start(self._token))
def main():
if os.path.exists("./config.toml"):
parser = OptionParser()
parser.add_option(
"-d", "--debug", dest="debug", help="Enable debug logging", action="store_true"
)
parser.add_option(
"-c", "--config", dest="config", help="Config file path"
)
(options, args) = parser.parse_args()
verbosity = logging.DEBUG if options.debug else logging.INFO
if options.config:
config = toml.load(options.config)
elif os.path.exists("./config.toml"):
config = toml.load("./config.toml")
elif os.path.exists("/etc/discord-xmpp-bridge/config.toml"):
config = toml.load("/etc/discord-xmpp-bridge/config.toml")
else:
raise Exception("config.toml not found")
parser = OptionParser()
parser.add_option(
"-d", "--debug", dest="debug", help="Enable debug logging", action="store_true"
)
(options, args) = parser.parse_args()
verbosity = logging.DEBUG if options.debug else logging.INFO
general = config["general"]
xmpp = BridgeComponent(general["jid"],
general["secret"],