diff --git a/redbot/core/cli.py b/redbot/core/cli.py index 272c4c2bd..ed4143fcf 100644 --- a/redbot/core/cli.py +++ b/redbot/core/cli.py @@ -89,6 +89,9 @@ def parse_cli_flags(args): parser.add_argument("--no-cogs", action="store_true", help="Starts Red with no cogs loaded, only core") + parser.add_argument("--load-cogs", type=str, nargs="*", + help="Force loading specified cogs from the installed packages. " + "Can be used with the --no-cogs flag to load these cogs exclusively.") parser.add_argument("--self-bot", action='store_true', help="Specifies if Red should log in as selfbot") @@ -126,3 +129,4 @@ def parse_cli_flags(args): args.prefix = [] return args + diff --git a/redbot/core/events.py b/redbot/core/events.py index 7a9bf22da..9b41eea7a 100644 --- a/redbot/core/events.py +++ b/redbot/core/events.py @@ -61,12 +61,17 @@ def init_events(bot, cli_flags): return bot.uptime = datetime.datetime.utcnow() + packages = [] if cli_flags.no_cogs is False: - print("Loading packages...") - failed = [] - packages = await bot.db.packages() + packages.extend(await bot.db.packages()) + if cli_flags.load_cogs: + packages.extend(cli_flags.load_cogs) + + if packages: + to_remove = [] + print("Loading packages...") for package in packages: try: spec = await bot.cog_mgr.find_cog(package) @@ -75,6 +80,9 @@ def init_events(bot, cli_flags): log.exception("Failed to load package {}".format(package), exc_info=e) await bot.remove_loaded_package(package) + to_remove.append(package) + for package in to_remove: + packages.remove(package) if packages: print("Loaded packages: " + ", ".join(packages)) @@ -277,3 +285,4 @@ def _get_startup_screen_specs(): ascii_border = False return on_symbol, off_symbol, ascii_border +