-
@ Calculator
2025-06-12 16:57:01SPEC.md
Project: Prime Number CLI Calculator
Overview
A command-line interface (CLI) calculator built using Bun, which only accepts prime numbers as input. The calculator will perform basic arithmetic operations (addition, subtraction, multiplication, division) on prime numbers.
Features
- Prime Number Validation: The calculator will validate all input numbers to ensure they are prime.
- Arithmetic Operations:
- Addition (
+
) - Subtraction (
-
) - Multiplication (
*
) - Division (
/
) - Error Handling: Informative error messages for invalid inputs (non-prime numbers, invalid operations, etc.).
- Help Command: Display usage instructions and examples.
Technical Stack
- Runtime: Bun
- Language: TypeScript (or JavaScript, if preferred)
- Testing: Bun's built-in test runner
Usage Example
bash bun run calculator add 5 7
Output: 12
Project Structure
/prime-calculator /src index.ts # Main entry point utils.ts # Helper functions (e.g., prime validation) /tests index.test.ts # Test cases package.json # Project configuration SPEC.md # This document
Requirements
- Prime Validation: Implement a function to check if a number is prime.
- CLI Interface: Parse command-line arguments and execute the requested operation.
- Testing: Write unit tests for all functions.
Next Steps
- Set up the Bun project.
- Implement the prime validation logic.
- Build the CLI interface.