diff --git a/plugin/adapter.py b/plugin/adapter.py index 9d3f7f3..cfaefce 100644 --- a/plugin/adapter.py +++ b/plugin/adapter.py @@ -2777,6 +2777,14 @@ class RocketChatAdapter(BasePlatformAdapter): "Subcommands: start, status, resume, pause, abort, reset. " "Ohne Subcommand: Status anzeigen.", 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( "curate", self._cmd_curate, diff --git a/plugin/archivar/inline_commands.py b/plugin/archivar/inline_commands.py index 29dbee4..1d9fddb 100644 --- a/plugin/archivar/inline_commands.py +++ b/plugin/archivar/inline_commands.py @@ -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 ────────────────────────── diff --git a/plugin/archivar/tests/test_r5_inline_commands.py b/plugin/archivar/tests/test_r5_inline_commands.py index b088172..38f8d6d 100644 --- a/plugin/archivar/tests/test_r5_inline_commands.py +++ b/plugin/archivar/tests/test_r5_inline_commands.py @@ -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 ────────────────────────────────────