From de229f63fe6303b57b2df7240b6e8afa0e17fd7f Mon Sep 17 00:00:00 2001 From: jack1142 <6032823+jack1142@users.noreply.github.com> Date: Fri, 27 Dec 2019 23:14:04 +0100 Subject: [PATCH] [Downloader] Add more information to `[p]repo info`, `[p]cog info` and `[p]findcog` (#3225) * Update downloader.py * Update downloader.py * Update downloader.py * Create 3225.enhance.1.rst * Create 3225.enhance.2.rst * Create 3225.enhance.3.rst * Update downloader.py * Style fix, ready for review --- changelog.d/downloader/3225.enhance.1.rst | 1 + changelog.d/downloader/3225.enhance.2.rst | 1 + changelog.d/downloader/3225.enhance.3.rst | 1 + redbot/cogs/downloader/downloader.py | 30 ++++++++++++++++++----- 4 files changed, 27 insertions(+), 6 deletions(-) create mode 100644 changelog.d/downloader/3225.enhance.1.rst create mode 100644 changelog.d/downloader/3225.enhance.2.rst create mode 100644 changelog.d/downloader/3225.enhance.3.rst diff --git a/changelog.d/downloader/3225.enhance.1.rst b/changelog.d/downloader/3225.enhance.1.rst new file mode 100644 index 000000000..fba6d761b --- /dev/null +++ b/changelog.d/downloader/3225.enhance.1.rst @@ -0,0 +1 @@ +``[p]repo info`` will now show repo's url, branch and authors. diff --git a/changelog.d/downloader/3225.enhance.2.rst b/changelog.d/downloader/3225.enhance.2.rst new file mode 100644 index 000000000..64fb79494 --- /dev/null +++ b/changelog.d/downloader/3225.enhance.2.rst @@ -0,0 +1 @@ +``[p]cog info`` will now show cog authors. diff --git a/changelog.d/downloader/3225.enhance.3.rst b/changelog.d/downloader/3225.enhance.3.rst new file mode 100644 index 000000000..f1b563472 --- /dev/null +++ b/changelog.d/downloader/3225.enhance.3.rst @@ -0,0 +1 @@ +``[p]findcog`` will now show repo's branch. diff --git a/redbot/cogs/downloader/downloader.py b/redbot/cogs/downloader/downloader.py index fffb8b103..3287977a5 100644 --- a/redbot/cogs/downloader/downloader.py +++ b/redbot/cogs/downloader/downloader.py @@ -506,10 +506,20 @@ class Downloader(commands.Cog): @repo.command(name="info", usage="") async def _repo_info(self, ctx: commands.Context, repo: Repo) -> None: """Show information about a repo.""" - msg = _("Information on {repo.name}:\n{description}").format( - repo=repo, description=repo.description or "" + made_by = ", ".join(repo.author) or _("Missing from info.json") + + information = _("Repo url: {repo_url}\n").format(repo_url=repo.clean_url) + if repo.branch: + information += _("Branch: {branch_name}\n").format(branch_name=repo.branch) + information += _("Made by: {author}\nDescription:\n{description}").format( + author=made_by, description=repo.description or "" ) - await ctx.send(box(msg)) + + msg = _("Information on {repo_name} repo:{information}").format( + repo_name=inline(repo.name), information=box(information) + ) + + await ctx.send(msg) @repo.command(name="update") async def _repo_update(self, ctx: commands.Context, *repos: Repo) -> None: @@ -944,10 +954,12 @@ class Downloader(commands.Cog): return msg = _( - "Information on {cog_name}:\n{description}\n\nRequirements: {requirements}" + "Information on {cog_name}:\n{description}\n\n" + "Made by: {author}\nRequirements: {requirements}" ).format( cog_name=cog.name, description=cog.description or "", + author=", ".join(cog.author) or _("Missing from info.json"), requirements=", ".join(cog.requirements) or "None", ) await ctx.send(box(msg)) @@ -1221,9 +1233,15 @@ class Downloader(commands.Cog): repo_url = "https://github.com/Cog-Creators/Red-DiscordBot" cog_name = cog_installable.__class__.__name__ - msg = _("Command: {command}\nMade by: {author}\nRepo: {repo_url}\nCog name: {cog}") + msg = _( + "Command: {command}\nCog name: {cog}\nMade by: {author}\nRepo: {repo_url}\n" + ).format(command=command_name, author=made_by, repo_url=repo_url, cog=cog_name) + if cog_installable.repo is not None and cog_installable.repo.branch: + msg += _("Repo branch: {branch_name}\n").format( + branch_name=cog_installable.repo.branch + ) - return msg.format(command=command_name, author=made_by, repo_url=repo_url, cog=cog_name) + return msg def cog_name_from_instance(self, instance: object) -> str: """Determines the cog name that Downloader knows from the cog instance.