mirror of
https://github.com/pocketpaw/pocketpaw.git
synced 2026-05-13 21:21:53 +00:00
fix(cli): reject --telegram combined with other channel flags (#743)
Telegram is the legacy pairing-only mode; combining it with --discord/--slack/--whatsapp/etc produced confusing startup state where the dashboard never came up but the extra channels silently ran. Fail fast via argparse error so the user gets a clear message. Uses `getattr(args, flag, False)` so unregistered flags don't crash. Leaves `_check_extras_installed` and the rest of the main() control flow untouched (earlier iterations of the PR moved it too early and broke `doctor`/`status`). Reduces the original test to the conflict cases only — asserting on the non-conflict path would require mocking the full startup pipeline. Co-Authored-By: Aravindavenge <119057955+Aravindavenge@users.noreply.github.com>
This commit is contained in:
@@ -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)
|
||||
|
||||
16
tests/test_cli_flags.py
Normal file
16
tests/test_cli_flags.py
Normal file
@@ -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
|
||||
Reference in New Issue
Block a user