fix: ::hilfe zeigt ::onboarding Subcommands einzeln mit Beschreibung
This commit is contained in:
@@ -2777,6 +2777,14 @@ class RocketChatAdapter(BasePlatformAdapter):
|
|||||||
"Subcommands: start, status, resume, pause, abort, reset. "
|
"Subcommands: start, status, resume, pause, abort, reset. "
|
||||||
"Ohne Subcommand: Status anzeigen.",
|
"Ohne Subcommand: Status anzeigen.",
|
||||||
category="Plugin",
|
category="Plugin",
|
||||||
|
subcommands={
|
||||||
|
"start": "Startet das Onboarding neu",
|
||||||
|
"status": "Zeigt den aktuellen Onboarding-Status mit Fortschritt",
|
||||||
|
"resume": "Setzt ein pausiertes Onboarding fort",
|
||||||
|
"pause": "Pausiert das Onboarding",
|
||||||
|
"abort": "Bricht das Onboarding ab (mit Bestätigung)",
|
||||||
|
"reset": "Hart-Reset des Onboarding-State, Backups bleiben",
|
||||||
|
},
|
||||||
)
|
)
|
||||||
self._inline_commands.register(
|
self._inline_commands.register(
|
||||||
"curate", self._cmd_curate,
|
"curate", self._cmd_curate,
|
||||||
|
|||||||
@@ -93,6 +93,7 @@ class InlineCommandRegistry:
|
|||||||
help_text: str,
|
help_text: str,
|
||||||
description: str = "",
|
description: str = "",
|
||||||
category: str = "Plugin",
|
category: str = "Plugin",
|
||||||
|
subcommands: Optional[Dict[str, str]] = None,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Registriert einen ::-Befehl.
|
"""Registriert einen ::-Befehl.
|
||||||
|
|
||||||
@@ -102,12 +103,15 @@ class InlineCommandRegistry:
|
|||||||
help_text: Kurzer Hilfetext (eine Zeile).
|
help_text: Kurzer Hilfetext (eine Zeile).
|
||||||
description: Ausführliche Beschreibung.
|
description: Ausführliche Beschreibung.
|
||||||
category: Kategorie für die Hilfeseite.
|
category: Kategorie für die Hilfeseite.
|
||||||
|
subcommands: Optionales Dict {subcmd: beschreibung} für Befehle
|
||||||
|
mit Subcommands (z.B. {'start': 'Startet...', ...}).
|
||||||
"""
|
"""
|
||||||
self._commands[name] = {
|
self._commands[name] = {
|
||||||
"handler": handler,
|
"handler": handler,
|
||||||
"help_text": help_text,
|
"help_text": help_text,
|
||||||
"description": description,
|
"description": description,
|
||||||
"category": category,
|
"category": category,
|
||||||
|
"subcommands": subcommands or {},
|
||||||
}
|
}
|
||||||
|
|
||||||
def get_handler(self, name: str) -> Optional[CommandHandler]:
|
def get_handler(self, name: str) -> Optional[CommandHandler]:
|
||||||
@@ -166,6 +170,9 @@ def build_help_text(registry: InlineCommandRegistry, room_map_summary: str = "")
|
|||||||
lines.append("")
|
lines.append("")
|
||||||
for cmd in standard_cmds:
|
for cmd in standard_cmds:
|
||||||
lines.append(f"- `::{cmd['name']}` — {cmd['help_text']}")
|
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("")
|
lines.append("")
|
||||||
|
|
||||||
# ── Sektion 2: RC-Plugin-spezifische Befehle ──────────────────────
|
# ── Sektion 2: RC-Plugin-spezifische Befehle ──────────────────────
|
||||||
@@ -182,6 +189,9 @@ def build_help_text(registry: InlineCommandRegistry, room_map_summary: str = "")
|
|||||||
lines.append("")
|
lines.append("")
|
||||||
for cmd in rc_cmds:
|
for cmd in rc_cmds:
|
||||||
lines.append(f"- `::{cmd['name']}` — {cmd['help_text']}")
|
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("")
|
lines.append("")
|
||||||
|
|
||||||
# ── Sektion 3: Natürliche Sprach-Befehle ──────────────────────────
|
# ── Sektion 3: Natürliche Sprach-Befehle ──────────────────────────
|
||||||
|
|||||||
@@ -732,6 +732,60 @@ class TestSectionedHelpText:
|
|||||||
text = build_help_text(registry)
|
text = build_help_text(registry)
|
||||||
assert "Rocket.Chat-Plugin direkt" in text
|
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 ────────────────────────────────────
|
# ── R5.1: Registry mit neuen Befehlen ────────────────────────────────────
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user