diff --git a/redbot/core/_cli.py b/redbot/core/_cli.py index e1fbd981989..350db0f533c 100644 --- a/redbot/core/_cli.py +++ b/redbot/core/_cli.py @@ -219,6 +219,15 @@ def parse_cli_flags(args): action="extend", help="Force unloading specified cogs.", ) + parser.add_argument( + "--cog-path", + type=str, + default=[], + nargs="+", + action="extend", + help="Add a specific path to the list of cog paths. " + "This can be used multiple times to add multiple paths.", + ) parser.add_argument( "--dry-run", action="store_true", diff --git a/redbot/core/bot.py b/redbot/core/bot.py index 359b65e3657..a551010c814 100644 --- a/redbot/core/bot.py +++ b/redbot/core/bot.py @@ -1240,6 +1240,15 @@ async def _pre_connect(self) -> None: ) ) + if self._cli_flags.cog_path: + for path in self._cli_flags.cog_path: + path = Path(path) + if not path.exists(): + log.warning("Cog path '%s' does not exist, skipping", path) + continue + await self._cog_mgr.add_path(path) + log.info("Added cog path: %s", path) + if packages: # Load permissions first, for security reasons try: