Skip to content

Commit b1674d8

Browse files
committed
Add --cog-path CLI argument
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 #6506
1 parent 71554c9 commit b1674d8

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

redbot/core/_cli.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,15 @@ def parse_cli_flags(args):
219219
action="extend",
220220
help="Force unloading specified cogs.",
221221
)
222+
parser.add_argument(
223+
"--cog-path",
224+
type=str,
225+
default=[],
226+
nargs="+",
227+
action="extend",
228+
help="Add a specific path to the list of cog paths. "
229+
"This can be used multiple times to add multiple paths.",
230+
)
222231
parser.add_argument(
223232
"--dry-run",
224233
action="store_true",

redbot/core/bot.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1240,6 +1240,15 @@ async def _pre_connect(self) -> None:
12401240
)
12411241
)
12421242

1243+
if self._cli_flags.cog_path:
1244+
for path in self._cli_flags.cog_path:
1245+
path = Path(path)
1246+
if not path.exists():
1247+
log.warning("Cog path '%s' does not exist, skipping", path)
1248+
continue
1249+
await self._cog_mgr.add_path(path)
1250+
log.info("Added cog path: %s", path)
1251+
12431252
if packages:
12441253
# Load permissions first, for security reasons
12451254
try:

0 commit comments

Comments
 (0)