Skip to content

Commit

Permalink
Add --cog-path CLI argument
Browse files Browse the repository at this point in the history
This argument takes a list of strings (can be used multiple times for more than one value), validates that the path provided exists, and adds the path via `self._cog_mgr.add_path()`, so that cogs can be loaded from that path.

Closes Cog-Creators#6506
  • Loading branch information
cswimr committed Feb 1, 2025
1 parent a0c1713 commit 1274059
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
9 changes: 9 additions & 0 deletions redbot/core/_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
9 changes: 9 additions & 0 deletions redbot/core/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -1221,6 +1221,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:
Expand Down

0 comments on commit 1274059

Please sign in to comment.