Structure webber into three independent subprojects: - webber-api/: FastAPI backend server with all agent code - webber-cli/: Standalone CLI client (renamed from cli/ to webber_cli/) - webber-sandbox/: Test project for functional testing Key changes: - Each subproject has its own .venv (Python 3.12+) - Added sandbox.sh for managing test project templates - Created sandbox-templates/ with calculator-cli and empty starter - Updated CI/CD for prefixed tags (api/v*, cli/v*) - Added comprehensive AGENTS.md with operational instructions - Added gitignore filtering to glob and grep tools - Created pyproject.toml for each subproject Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
56 lines
1.3 KiB
Python
56 lines
1.3 KiB
Python
#!/usr/bin/env python3
|
|
"""
|
|
Calculator CLI - A simple command-line calculator.
|
|
|
|
NOTE: This file contains intentional bugs for testing purposes.
|
|
|
|
Usage:
|
|
python -m calculator.main 10 5 add
|
|
python -m calculator.main 10 5 sub
|
|
python -m calculator.main 10 5 mul
|
|
python -m calculator.main 10 5 div
|
|
"""
|
|
import sys
|
|
|
|
from calculator.operations import add, subtract, multiply, divide
|
|
|
|
|
|
def get_operation(op_name: str):
|
|
"""
|
|
Get the operation function by name.
|
|
|
|
BUG: No validation - invalid operation names cause KeyError!
|
|
"""
|
|
operations = {
|
|
"add": add,
|
|
"sub": subtract,
|
|
"mul": multiply,
|
|
"div": divide,
|
|
# BUG: 'power' is implemented in operations.py but not exposed here
|
|
}
|
|
# BUG: Should handle KeyError gracefully
|
|
return operations[op_name]
|
|
|
|
|
|
def main():
|
|
"""Main entry point."""
|
|
if len(sys.argv) != 4:
|
|
print("Usage: python -m calculator.main <a> <b> <operation>")
|
|
print("Operations: add, sub, mul, div")
|
|
sys.exit(1)
|
|
|
|
# BUG: No validation that a and b are valid numbers
|
|
a = float(sys.argv[1])
|
|
b = float(sys.argv[2])
|
|
op_name = sys.argv[3]
|
|
|
|
# BUG: This will crash with KeyError for invalid operation
|
|
operation = get_operation(op_name)
|
|
result = operation(a, b)
|
|
|
|
print(f"Result: {result}")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|