Clean up help-entry display a bit

This commit is contained in:
Griatch 2021-05-29 16:10:54 +02:00
parent c7fb61de0f
commit d482d2bec0

View file

@ -150,7 +150,7 @@ class CmdHelp(COMMAND_DEFAULT_CLASS):
else: else:
aliases = '' aliases = ''
help_text = "\n\n" + dedent(help_text.strip('\n')) + "\n" if help_text else "" help_text = "\n" + dedent(help_text.strip('\n')) if help_text else ""
if subtopics: if subtopics:
subtopics = [f"|w{topic}/{subtop}|n" for subtop in subtopics] subtopics = [f"|w{topic}/{subtop}|n" for subtop in subtopics]
@ -164,15 +164,17 @@ class CmdHelp(COMMAND_DEFAULT_CLASS):
if suggested: if suggested:
suggested = [f"|w{sug}|n" for sug in suggested] suggested = [f"|w{sug}|n" for sug in suggested]
suggested = ( suggested = (
"\n|CSuggestions:|n\n{}".format( "\n|COther topic suggestions:|n\n{}".format(
"\n ".join(format_grid(suggested, width=self.client_width()))) "\n ".join(format_grid(suggested, width=self.client_width())))
) )
else: else:
suggested = '' suggested = ''
end = f"\n{separator}" end = start
return "".join((start, title, aliases, help_text, subtopics, suggested, end)) partorder = (start, title + aliases, help_text, subtopics, suggested, end)
return "\n".join(part.rstrip() for part in partorder if part)
def format_help_index(self, cmd_help_dict=None, db_help_dict=None, title_lone_category=False): def format_help_index(self, cmd_help_dict=None, db_help_dict=None, title_lone_category=False):
""" """
@ -420,7 +422,9 @@ class CmdHelp(COMMAND_DEFAULT_CLASS):
) )
if suggestions: if suggestions:
help_text += "\n... But matches where found within the help texts of the suggestions below." help_text += (
"\n... But matches where found within the help "
"texts of the suggestions below.")
break break
output = self.format_help_entry( output = self.format_help_entry(
@ -524,7 +528,8 @@ class CmdHelp(COMMAND_DEFAULT_CLASS):
topic=topic, topic=topic,
help_text=help_text, help_text=help_text,
aliases=aliases if not subtopics else None, aliases=aliases if not subtopics else None,
subtopics=subtopic_index subtopics=subtopic_index,
suggested=suggested
) )
self.msg_help(output) self.msg_help(output)