Skip to content

Commit c4da44b

Browse files
fix(cli): invoke module entrypoint
1 parent a90219f commit c4da44b

2 files changed

Lines changed: 26 additions & 0 deletions

File tree

tests/test_cli.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
"""Tests for CLI functions, particularly parse_api_keys."""
22

3+
import pathlib
4+
import subprocess
5+
import sys
6+
37
import pytest
48
from weco.cli import parse_api_keys
59

@@ -68,3 +72,21 @@ def test_parse_api_keys_mixed_case_provider(self):
6872
"""Test that mixed case providers are normalized correctly."""
6973
result = parse_api_keys(["OpenAI=sk-xxx", "ANTHROPIC=sk-ant-yyy"])
7074
assert result == {"openai": "sk-xxx", "anthropic": "sk-ant-yyy"}
75+
76+
77+
def test_module_execution_invokes_cli_help():
78+
"""Running the module directly should invoke the CLI entrypoint."""
79+
repo_root = pathlib.Path(__file__).resolve().parent.parent
80+
result = subprocess.run(
81+
[sys.executable, "-m", "weco.cli", "setup", "--help"],
82+
cwd=repo_root,
83+
capture_output=True,
84+
text=True,
85+
check=False,
86+
)
87+
88+
assert result.returncode == 0
89+
assert "usage:" in result.stdout
90+
assert "claude-code" in result.stdout
91+
assert "codex" in result.stdout
92+
assert "openclaw" in result.stdout

weco/cli.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -645,3 +645,7 @@ def _main() -> None:
645645
# or if an invalid command is provided.
646646
parser.print_help() # Default action if no command given and not chatbot.
647647
sys.exit(1)
648+
649+
650+
if __name__ == "__main__":
651+
main()

0 commit comments

Comments
 (0)