diff --git a/src/pocketpaw/__main__.py b/src/pocketpaw/__main__.py index 5828d8b3..03b059dd 100644 --- a/src/pocketpaw/__main__.py +++ b/src/pocketpaw/__main__.py @@ -424,6 +424,14 @@ def main() -> None: args = parser.parse_args() _resolve_subargs(args) + # Reject combining --telegram with other channel flags. Telegram is the + # legacy pairing-only path; other channels require the dashboard. + _other_channel_flags = ("discord", "slack", "whatsapp", "signal", "matrix", "teams", "gchat") + if getattr(args, "telegram", False) and any( + getattr(args, f, False) for f in _other_channel_flags + ): + parser.error("--telegram cannot be combined with other channel flags") + # ── Early-exit commands (no settings, health, or env setup needed) ── if args.command in _EARLY_COMMANDS: exit_code = _handle_early_command(args) diff --git a/tests/test_cli_flags.py b/tests/test_cli_flags.py new file mode 100644 index 00000000..91e67a6e --- /dev/null +++ b/tests/test_cli_flags.py @@ -0,0 +1,16 @@ +"""Tests for CLI flag validation in pocketpaw.__main__.""" + +from __future__ import annotations + +import pytest + + +@pytest.mark.parametrize("conflict_flag", ["--discord", "--slack", "--whatsapp"]) +def test_telegram_conflicts_with_other_channel_flag(monkeypatch, conflict_flag): + """--telegram combined with another channel flag must exit via argparse error (code 2).""" + from pocketpaw.__main__ import main + + monkeypatch.setattr("sys.argv", ["pocketpaw", "--telegram", conflict_flag]) + with pytest.raises(SystemExit) as exc_info: + main() + assert exc_info.value.code == 2