[Downloader] Allow removal of multiple repos (#5082)

* add multi repo support + docstring

* update docs

* Update redbot/cogs/downloader/downloader.py

Co-authored-by: jack1142 <6032823+jack1142@users.noreply.github.com>

* style

* Update redbot/cogs/downloader/downloader.py

Co-authored-by: jack1142 <6032823+jack1142@users.noreply.github.com>
This commit is contained in:
Vexed 2021-05-27 13:47:41 +01:00 committed by GitHub
parent 23997d7a71
commit 210c07d5a7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 10 deletions

View File

@ -461,14 +461,15 @@ repo delete
**Description** **Description**
Remove a repo and its files. Remove repos and their files.
Example: Examples:
- ``[p]repo delete 26-Cogs`` - ``[p]repo delete 26-Cogs``
- ``[p]repo delete 26-Cogs Laggrons-Dumb-Cogs``
**Arguments** **Arguments**
- ``<repo>`` The name of an already added repo - ``<repos...>`` The repo or repos to remove.
.. _downloader-command-repo-info: .. _downloader-command-repo-info:

View File

@ -583,22 +583,29 @@ class Downloader(commands.Cog):
if repo.install_msg: if repo.install_msg:
await ctx.send(repo.install_msg.replace("[p]", ctx.clean_prefix)) await ctx.send(repo.install_msg.replace("[p]", ctx.clean_prefix))
@repo.command(name="delete", aliases=["remove", "del"]) @repo.command(name="delete", aliases=["remove", "del"], require_var_positional=True)
async def _repo_del(self, ctx: commands.Context, repo: Repo) -> None: async def _repo_del(self, ctx: commands.Context, *repos: Repo) -> None:
""" """
Remove a repo and its files. Remove repos and their files.
Example: Examples:
- `[p]repo delete 26-Cogs` - `[p]repo delete 26-Cogs`
- `[p]repo delete 26-Cogs Laggrons-Dumb-Cogs`
**Arguments** **Arguments**
- `<repo>` The name of an already added repo - `<repos...>` The repo or repos to remove.
""" """
for repo in set(repos):
await self._repo_manager.delete_repo(repo.name) await self._repo_manager.delete_repo(repo.name)
await ctx.send( await ctx.send(
_("The repo `{repo.name}` has been deleted successfully.").format(repo=repo) (
_("Successfully deleted repos: ")
if len(repos) > 1
else _("Successfully deleted the repo: ")
)
+ humanize_list([inline(i.name) for i in set(repos)])
) )
@repo.command(name="list") @repo.command(name="list")