From 8ab23c63ab2d7baf0d0d30297fe661b2d5df9f94 Mon Sep 17 00:00:00 2001 From: "Alexander \"PapaTutuWawa" Date: Thu, 25 Nov 2021 22:31:03 +0100 Subject: [PATCH] main: Accept the config file from the cli --- xmpp_discord_bridge/main.py | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/xmpp_discord_bridge/main.py b/xmpp_discord_bridge/main.py index 0942749..bb7f7fc 100644 --- a/xmpp_discord_bridge/main.py +++ b/xmpp_discord_bridge/main.py @@ -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"],