fork of https://f-hub.org/XMPP/xmpp-discord-bridge

main: Accept the config file from the cli

+13 -8
+13 -8
xmpp_discord_bridge/main.py
··· 489 489 asyncio.ensure_future(self._discord.start(self._token)) 490 490 491 491 def main(): 492 - if os.path.exists("./config.toml"): 493 - config = toml.load("./config.toml") 494 - elif os.path.exists("/etc/discord-xmpp-bridge/config.toml"): 495 - config = toml.load("/etc/discord-xmpp-bridge/config.toml") 496 - else: 497 - raise Exception("config.toml not found") 498 - 499 492 parser = OptionParser() 500 493 parser.add_option( 501 494 "-d", "--debug", dest="debug", help="Enable debug logging", action="store_true" 502 495 ) 496 + parser.add_option( 497 + "-c", "--config", dest="config", help="Config file path" 498 + ) 503 499 504 500 (options, args) = parser.parse_args() 505 501 verbosity = logging.DEBUG if options.debug else logging.INFO 506 - 502 + 503 + if options.config: 504 + config = toml.load(options.config) 505 + elif os.path.exists("./config.toml"): 506 + config = toml.load("./config.toml") 507 + elif os.path.exists("/etc/discord-xmpp-bridge/config.toml"): 508 + config = toml.load("/etc/discord-xmpp-bridge/config.toml") 509 + else: 510 + raise Exception("config.toml not found") 511 + 507 512 general = config["general"] 508 513 xmpp = BridgeComponent(general["jid"], 509 514 general["secret"],