Skip to content

Commit

Permalink
chore: single print for help command
Browse files Browse the repository at this point in the history
  • Loading branch information
phil65 committed Feb 2, 2025
1 parent 755faa7 commit 3e2f33d
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions src/slashed/builtin/help_cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ async def help_command(
):
"""Show available commands or detailed help for a specific command."""
store = ctx.command_store
output_lines = []

if args: # Detail for specific command
name = args[0]
Expand All @@ -49,19 +50,20 @@ async def help_command(
if cmd.help_text:
sections.extend(["Help:", cmd.help_text])

await ctx.output.print("\n".join(sections))
output_lines.extend(sections)
else:
await ctx.output.print(f"Unknown command: {name}")
return

# List all commands grouped by category
categories = store.get_commands_by_category()

await ctx.output.print("\nAvailable commands:")
for category, commands in categories.items():
await ctx.output.print(f"\n{category.title()}:")
for cmd in commands:
await ctx.output.print(f" /{cmd.name:<16} - {cmd.description}")
output_lines.append(f"Unknown command: {name}")
else:
# List all commands grouped by category
categories = store.get_commands_by_category()
output_lines.append("\nAvailable commands:")
for category, commands in categories.items():
output_lines.extend([
f"\n{category.title()}:",
*[f" /{cmd.name:<16} - {cmd.description}" for cmd in commands],
])

await ctx.output.print("\n".join(output_lines))


def create_help_completer() -> CompletionProvider:
Expand Down

0 comments on commit 3e2f33d

Please sign in to comment.