fix: ::hilfe zeigt ::onboarding Subcommands einzeln mit Beschreibung

This commit is contained in:
Bernd (Hermes)
2026-07-19 20:28:38 +02:00
parent 7298459fc8
commit 4604f2e123
3 changed files with 72 additions and 0 deletions
+10
View File
@@ -93,6 +93,7 @@ class InlineCommandRegistry:
help_text: str,
description: str = "",
category: str = "Plugin",
subcommands: Optional[Dict[str, str]] = None,
) -> None:
"""Registriert einen ::-Befehl.
@@ -102,12 +103,15 @@ class InlineCommandRegistry:
help_text: Kurzer Hilfetext (eine Zeile).
description: Ausführliche Beschreibung.
category: Kategorie für die Hilfeseite.
subcommands: Optionales Dict {subcmd: beschreibung} für Befehle
mit Subcommands (z.B. {'start': 'Startet...', ...}).
"""
self._commands[name] = {
"handler": handler,
"help_text": help_text,
"description": description,
"category": category,
"subcommands": subcommands or {},
}
def get_handler(self, name: str) -> Optional[CommandHandler]:
@@ -166,6 +170,9 @@ def build_help_text(registry: InlineCommandRegistry, room_map_summary: str = "")
lines.append("")
for cmd in standard_cmds:
lines.append(f"- `::{cmd['name']}` — {cmd['help_text']}")
subcmds = cmd.get('subcommands', {})
for sub_name, sub_desc in subcmds.items():
lines.append(f" - `::{cmd['name']} {sub_name}` — {sub_desc}")
lines.append("")
# ── Sektion 2: RC-Plugin-spezifische Befehle ──────────────────────
@@ -182,6 +189,9 @@ def build_help_text(registry: InlineCommandRegistry, room_map_summary: str = "")
lines.append("")
for cmd in rc_cmds:
lines.append(f"- `::{cmd['name']}` — {cmd['help_text']}")
subcmds = cmd.get('subcommands', {})
for sub_name, sub_desc in subcmds.items():
lines.append(f" - `::{cmd['name']} {sub_name}` — {sub_desc}")
lines.append("")
# ── Sektion 3: Natürliche Sprach-Befehle ──────────────────────────
@@ -732,6 +732,60 @@ class TestSectionedHelpText:
text = build_help_text(registry)
assert "Rocket.Chat-Plugin direkt" in text
def test_help_text_renders_subcommands(self):
"""Befehle mit subcommands werden mit eingerückten Unterpunkten gerendert."""
from archivar.inline_commands import InlineCommandRegistry, build_help_text
registry = InlineCommandRegistry()
async def dummy(room_id, args):
return "ok"
registry.register(
"onboarding", dummy,
help_text="Onboarding steuern",
category="Plugin",
subcommands={
"start": "Startet das Onboarding neu",
"status": "Zeigt den aktuellen Onboarding-Status",
"resume": "Setzt ein pausiertes Onboarding fort",
"pause": "Pausiert das Onboarding",
"abort": "Bricht das Onboarding ab",
"reset": "Hart-Reset des Onboarding-State",
},
)
text = build_help_text(registry)
assert "::onboarding" in text
assert "::onboarding start" in text
assert "::onboarding status" in text
assert "::onboarding resume" in text
assert "::onboarding pause" in text
assert "::onboarding abort" in text
assert "::onboarding reset" in text
assert "Startet das Onboarding neu" in text
assert "Zeigt den aktuellen Onboarding-Status" in text
assert "Setzt ein pausiertes Onboarding fort" in text
assert "Pausiert das Onboarding" in text
assert "Bricht das Onboarding ab" in text
assert "Hart-Reset des Onboarding-State" in text
def test_help_text_command_without_subcommands_no_indent(self):
"""Befehle ohne subcommands haben keine eingerückten Unterpunkte."""
from archivar.inline_commands import InlineCommandRegistry, build_help_text
registry = InlineCommandRegistry()
async def dummy(room_id, args):
return "ok"
registry.register("multiroom", dummy, "Multi-Room", category="Plugin")
text = build_help_text(registry)
# Sollte keine eingerückten Zeilen haben (keine subcommands)
lines = text.split("\n")
for line in lines:
if "multiroom" in line:
assert not line.startswith(" -"), f"Unexpected indent: {line}"
# ── R5.1: Registry mit neuen Befehlen ────────────────────────────────────