feat: add CLI with build and run commands

This commit is contained in:
2026-05-03 12:58:29 -05:00
parent 3067141e5d
commit c760a98e60
12 changed files with 200 additions and 122 deletions

42
tests/test_cli.py Normal file
View File

@@ -0,0 +1,42 @@
"""Test CLI functionality."""
import os
import subprocess
import sys
from pathlib import Path
def test_build_command():
"""Test build command."""
result = subprocess.run(
[sys.executable, "-m", "tampy", "build", "test.tampy"],
capture_output=True,
text=True,
env={**dict(os.environ), "PYTHONPATH": "src"}
)
assert result.returncode == 0
assert "Generated:" in result.stdout
def test_run_command():
"""Test run command."""
result = subprocess.run(
[sys.executable, "-m", "tampy", "run", "test.tampy"],
capture_output=True,
text=True,
env={**dict(os.environ), "PYTHONPATH": "src"}
)
assert result.returncode == 0
assert "y is greater" in result.stdout
def test_file_extension_replacement():
"""Test that .tampy is replaced with .py."""
result = subprocess.run(
[sys.executable, "-m", "tampy", "build", "test.tampy"],
capture_output=True,
text=True,
env={**dict(os.environ), "PYTHONPATH": "src"}
)
assert result.returncode == 0
assert Path("test.py").exists()