From d641ca86dbb43882418e6c4481f7af56c0f4bb6c Mon Sep 17 00:00:00 2001 From: Volcyy Date: Sat, 5 May 2018 10:13:38 +0200 Subject: Show alternative syntax in help texts for `bot.tags.keys()` and `bot.tags` (#64) * Show different footer for `keys` and `get`. * Add alternative syntax invocation to help command. * Differentiate between `()` in command invocation or not. --- bot/cogs/tags.py | 9 ++++++++- bot/formatter.py | 7 +++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/bot/cogs/tags.py b/bot/cogs/tags.py index 1c8f54d9f..a7c6b0248 100644 --- a/bot/cogs/tags.py +++ b/bot/cogs/tags.py @@ -251,11 +251,18 @@ class Tags: # Paginate if this is a list of all tags if tags: + if ctx.invoked_with == "tags.keys()": + detail_invocation = "bot.tags[]" + elif ctx.invoked_with == "tags.get()": + detail_invocation = "bot.tags.get()" + else: + detail_invocation = "bot.tags.get " + log.debug(f"Returning a paginated list of all tags.") return await LinePaginator.paginate( (lines for lines in tags), ctx, embed, - footer_text="To show a tag, type bot.tags.get .", + footer_text=f"To show a tag, type {detail_invocation}.", empty=False, max_lines=15 ) diff --git a/bot/formatter.py b/bot/formatter.py index f46aaa685..7c966108a 100644 --- a/bot/formatter.py +++ b/bot/formatter.py @@ -35,6 +35,13 @@ class Formatter(HelpFormatter): shortened = self.shorten(entry) self._paginator.add_line(shortened) + if name.endswith('get()'): + alternate_syntax_entry = " {0}{1:<{width}} # {2}".format( + HELP_PREFIX, name.split('.')[0] + '[]', + f"Alternative syntax for {name}", width=max_width + ) + self._paginator.add_line(self.shorten(alternate_syntax_entry)) + async def format(self): """ rewritten help command to make it more python-y -- cgit v1.2.3