Make command usage in help for required arguments consistent (#4589)

* Make command usage in help for required arguments consistent

* Bob 3

* Bob 1

* Docstring updates

* Address Flame's review

* Update cog guides in docs
This commit is contained in:
jack1142
2020-12-22 20:14:47 +01:00
committed by GitHub
parent 59e1e31634
commit b36a702e62
9 changed files with 109 additions and 214 deletions

View File

@@ -478,7 +478,7 @@ class Downloader(commands.Cog):
for page in pagify(content):
await target.send(page)
@commands.command()
@commands.command(require_var_positional=True)
@checks.is_owner()
async def pipinstall(self, ctx: commands.Context, *deps: str) -> None:
"""
@@ -492,11 +492,8 @@ class Downloader(commands.Cog):
**Arguments**
- `[deps...]` The package or packages you wish to install.
- `<deps...>` The package or packages you wish to install.
"""
if not deps:
await ctx.send_help()
return
repo = Repo("", "", "", "", Path.cwd())
async with ctx.typing():
success = await repo.install_raw_requirements(deps, self.LIB_PATH)
@@ -582,7 +579,7 @@ class Downloader(commands.Cog):
if repo.install_msg:
await ctx.send(repo.install_msg.replace("[p]", ctx.clean_prefix))
@repo.command(name="delete", aliases=["remove", "del"], usage="<repo_name>")
@repo.command(name="delete", aliases=["remove", "del"])
async def _repo_del(self, ctx: commands.Context, repo: Repo) -> None:
"""
Remove a repo and its files.
@@ -592,7 +589,7 @@ class Downloader(commands.Cog):
**Arguments**
- `<repo_name>` The name of an already added repo
- `<repo>` The name of an already added repo
"""
await self._repo_manager.delete_repo(repo.name)
@@ -612,7 +609,7 @@ class Downloader(commands.Cog):
for page in pagify(joined, ["\n"], shorten_by=16):
await ctx.send(box(page.lstrip(" "), lang="diff"))
@repo.command(name="info", usage="<repo_name>")
@repo.command(name="info")
async def _repo_info(self, ctx: commands.Context, repo: Repo) -> None:
"""Show information about a repo.
@@ -621,7 +618,7 @@ class Downloader(commands.Cog):
**Arguments**
- `<repo_name>` The name of the repo to show info about.
- `<repo>` The name of the repo to show info about.
"""
made_by = ", ".join(repo.author) or _("Missing from info.json")
@@ -737,7 +734,7 @@ class Downloader(commands.Cog):
)
)
@cog.command(name="install", usage="<repo_name> <cogs>")
@cog.command(name="install", usage="<repo> <cogs...>", require_var_positional=True)
async def _cog_install(self, ctx: commands.Context, repo: Repo, *cog_names: str) -> None:
"""Install a cog from the given repo.
@@ -747,14 +744,16 @@ class Downloader(commands.Cog):
**Arguments**
- `<repo_name>` The name of the repo to install cogs from.
- `<cogs>` The cog or cogs to install.
- `<repo>` The name of the repo to install cogs from.
- `<cogs...>` The cog or cogs to install.
"""
await self._cog_installrev(ctx, repo, None, cog_names)
@cog.command(name="installversion", usage="<repo_name> <revision> <cogs>")
@cog.command(
name="installversion", usage="<repo> <revision> <cogs...>", require_var_positional=True
)
async def _cog_installversion(
self, ctx: commands.Context, repo: Repo, rev: str, *cog_names: str
self, ctx: commands.Context, repo: Repo, revision: str, *cog_names: str
) -> None:
"""Install a cog from the specified revision of given repo.
@@ -768,18 +767,15 @@ class Downloader(commands.Cog):
**Arguments**
- `<repo_name>` The name of the repo to install cogs from.
- `<repo>` The name of the repo to install cogs from.
- `<revision>` The revision to install from.
- `<cogs>` The cog or cogs to install.
- `<cogs...>` The cog or cogs to install.
"""
await self._cog_installrev(ctx, repo, rev, cog_names)
await self._cog_installrev(ctx, repo, revision, cog_names)
async def _cog_installrev(
self, ctx: commands.Context, repo: Repo, rev: Optional[str], cog_names: Iterable[str]
) -> None:
if not cog_names:
await ctx.send_help()
return
commit = None
async with ctx.typing():
if rev is not None:
@@ -859,8 +855,8 @@ class Downloader(commands.Cog):
"\nYou can load them using {command_1}."
" To see end user data statements, you can use {command_2}."
).format(
command_1=inline(f"{ctx.clean_prefix}load <cogs>"),
command_2=inline(f"{ctx.clean_prefix}cog info <repo_name> <cog_name>"),
command_1=inline(f"{ctx.clean_prefix}load <cogs...>"),
command_2=inline(f"{ctx.clean_prefix}cog info <repo> <cog>"),
)
+ message
)
@@ -870,7 +866,7 @@ class Downloader(commands.Cog):
if cog.install_msg:
await ctx.send(cog.install_msg.replace("[p]", ctx.clean_prefix))
@cog.command(name="uninstall", usage="<cogs>")
@cog.command(name="uninstall", require_var_positional=True)
async def _cog_uninstall(self, ctx: commands.Context, *cogs: InstalledCog) -> None:
"""Uninstall cogs.
@@ -883,11 +879,8 @@ class Downloader(commands.Cog):
**Arguments**
- `<cogs>` The cog or cogs to uninstall.
- `<cogs...>` The cog or cogs to uninstall.
"""
if not cogs:
await ctx.send_help()
return
async with ctx.typing():
uninstalled_cogs = []
failed_cogs = []
@@ -923,7 +916,7 @@ class Downloader(commands.Cog):
)
await self.send_pagified(ctx, message)
@cog.command(name="pin", usage="<cogs>")
@cog.command(name="pin", require_var_positional=True)
async def _cog_pin(self, ctx: commands.Context, *cogs: InstalledCog) -> None:
"""Pin cogs - this will lock cogs on their current version.
@@ -933,11 +926,8 @@ class Downloader(commands.Cog):
**Arguments**
- `<cogs>` The cog or cogs to pin. Must already be installed.
- `<cogs...>` The cog or cogs to pin. Must already be installed.
"""
if not cogs:
await ctx.send_help()
return
already_pinned = []
pinned = []
for cog in set(cogs):
@@ -955,7 +945,7 @@ class Downloader(commands.Cog):
message += _("\nThese cogs were already pinned: ") + humanize_list(already_pinned)
await self.send_pagified(ctx, message)
@cog.command(name="unpin", usage="<cogs>")
@cog.command(name="unpin", require_var_positional=True)
async def _cog_unpin(self, ctx: commands.Context, *cogs: InstalledCog) -> None:
"""Unpin cogs - this will remove the update lock from those cogs.
@@ -965,10 +955,7 @@ class Downloader(commands.Cog):
**Arguments**
- `<cogs>` The cog or cogs to unpin. Must already be installed and pinned."""
if not cogs:
await ctx.send_help()
return
- `<cogs...>` The cog or cogs to unpin. Must already be installed and pinned."""
not_pinned = []
unpinned = []
for cog in set(cogs):
@@ -1062,7 +1049,7 @@ class Downloader(commands.Cog):
"""
await self._cog_update_logic(ctx, cogs=cogs)
@cog.command(name="updateallfromrepos", usage="<repos>")
@cog.command(name="updateallfromrepos", require_var_positional=True)
async def _cog_updateallfromrepos(self, ctx: commands.Context, *repos: Repo) -> None:
"""Update all cogs from repos of your choosing.
@@ -1072,16 +1059,13 @@ class Downloader(commands.Cog):
**Arguments**
- `<repos>` The repo or repos to update all cogs from.
- `<repos...>` The repo or repos to update all cogs from.
"""
if not repos:
await ctx.send_help()
return
await self._cog_update_logic(ctx, repos=repos)
@cog.command(name="updatetoversion", usage="<repo_name> <revision> [cogs]")
@cog.command(name="updatetoversion")
async def _cog_updatetoversion(
self, ctx: commands.Context, repo: Repo, rev: str, *cogs: InstalledCog
self, ctx: commands.Context, repo: Repo, revision: str, *cogs: InstalledCog
) -> None:
"""Update all cogs, or ones of your choosing to chosen revision of one repo.
@@ -1096,11 +1080,11 @@ class Downloader(commands.Cog):
**Arguments**
- `<repo_name>` The repo or repos to update all cogs from.
- `<repo>` The repo or repos to update all cogs from.
- `<revision>` The revision to update to.
- `[cogs]` The cog or cogs to update.
- `[cogs...]` The cog or cogs to update.
"""
await self._cog_update_logic(ctx, repo=repo, rev=rev, cogs=cogs)
await self._cog_update_logic(ctx, repo=repo, rev=revision, cogs=cogs)
async def _cog_update_logic(
self,
@@ -1219,7 +1203,7 @@ class Downloader(commands.Cog):
if updates_available and updated_cognames:
await self._ask_for_cog_reload(ctx, updated_cognames)
@cog.command(name="list", usage="<repo_name>")
@cog.command(name="list")
async def _cog_list(self, ctx: commands.Context, repo: Repo) -> None:
"""List all available cogs from a single repo.
@@ -1228,7 +1212,7 @@ class Downloader(commands.Cog):
**Arguments**
- `<repo_name>` The repo to list cogs from.
- `<repo>` The repo to list cogs from.
"""
installed = await self.installed_cogs()
installed_str = ""
@@ -1251,7 +1235,7 @@ class Downloader(commands.Cog):
for page in pagify(cogs, ["\n"], shorten_by=16):
await ctx.send(box(page.lstrip(" "), lang="diff"))
@cog.command(name="info", usage="<repo_name> <cog_name>")
@cog.command(name="info", usage="<repo> <cog>")
async def _cog_info(self, ctx: commands.Context, repo: Repo, cog_name: str) -> None:
"""List information about a single cog.
@@ -1260,8 +1244,8 @@ class Downloader(commands.Cog):
**Arguments**
- `<repo_name>` The repo to get cog info from.
- `<cog_name>` The cog to get info on.
- `<repo>` The repo to get cog info from.
- `<cog>` The cog to get info on.
"""
cog = discord.utils.get(repo.available_cogs, name=cog_name)
if cog is None:
@@ -1490,7 +1474,7 @@ class Downloader(commands.Cog):
_("\nEnd user data statements of these cogs have changed: ")
+ humanize_list(tuple(map(inline, cogs_with_changed_eud_statement)))
+ _("\nYou can use {command} to see the updated statements.\n").format(
command=inline(f"{ctx.clean_prefix}cog info <repo_name> <cog_name>")
command=inline(f"{ctx.clean_prefix}cog info <repo> <cog>")
)
)
if failed_cogs: