|
| 1 | +# SumCLI |
| 2 | + |
| 3 | +A simple command-line calculator that adds two numbers together. |
| 4 | + |
| 5 | +## Description |
| 6 | + |
| 7 | +SumCLI is a lightweight C-based command-line tool that performs addition of two numbers. It accepts two numeric |
| 8 | +arguments and returns their sum with two decimal places precision. |
| 9 | + |
| 10 | +## Features |
| 11 | + |
| 12 | +- ✅ Add two numbers (integers or decimals) |
| 13 | +- ✅ Input validation and error handling |
| 14 | +- ✅ Help documentation |
| 15 | +- ✅ Automated testing with TUI Test framework |
| 16 | +- ✅ CI/CD pipeline with compliance checks |
| 17 | + |
| 18 | +## Installation |
| 19 | + |
| 20 | +### Prerequisites |
| 21 | + |
| 22 | +- C compiler (GCC or Clang) |
| 23 | +- CMake (for building) |
| 24 | +- Node.js and npm (for running tests) |
| 25 | + |
| 26 | +### Build from Source |
| 27 | + |
| 28 | +1. Clone the repository: |
| 29 | + ```bash |
| 30 | + git clone https://github.com/Interes-Group/cli_testing_poc |
| 31 | + cd cli_testing_poc |
| 32 | + ``` |
| 33 | + |
| 34 | +2. Create build directory and compile: |
| 35 | + ```bash |
| 36 | + mkdir build |
| 37 | + cd build |
| 38 | + cmake .. |
| 39 | + make |
| 40 | + ``` |
| 41 | + |
| 42 | +It can be compiled with only gcc compiler |
| 43 | +```bash |
| 44 | +gcc -std=c17 -o sumcli -Wall -Wextra main.c |
| 45 | +``` |
| 46 | + |
| 47 | +3. The executable `sumcli` will be created in the build directory. |
| 48 | + |
| 49 | +## Usage |
| 50 | + |
| 51 | +```bash |
| 52 | +sumcli <first_number> <second_number> |
| 53 | +``` |
| 54 | + |
| 55 | +### Examples |
| 56 | + |
| 57 | +```bash |
| 58 | +# Add two integers |
| 59 | +./sumcli 5 3 |
| 60 | +# Output: The sum is 8.00 |
| 61 | + |
| 62 | +# Add decimal numbers |
| 63 | +./sumcli 2.5 1.7 |
| 64 | +# Output: The sum is 4.20 |
| 65 | + |
| 66 | +# Add negative numbers |
| 67 | +./sumcli -10 15 |
| 68 | +# Output: The sum is 5.00 |
| 69 | +``` |
| 70 | + |
| 71 | +### Help |
| 72 | + |
| 73 | +```bash |
| 74 | +./sumcli |
| 75 | +# Shows usage information and help text |
| 76 | +``` |
| 77 | + |
| 78 | +## Error Handling |
| 79 | + |
| 80 | +The application provides clear error messages for common issues: |
| 81 | + |
| 82 | +- **Too few arguments**: Displays error message and help when less than 2 numbers are provided |
| 83 | +- **Too many arguments**: Displays error message and help when more than 2 numbers are provided |
| 84 | +- **Invalid input**: Uses `atof()` which handles invalid numeric input gracefully |
| 85 | + |
| 86 | +## Testing |
| 87 | + |
| 88 | +This project uses the Microsoft TUI Test framework for automated testing. |
| 89 | + |
| 90 | +### Run Tests |
| 91 | + |
| 92 | +```bash |
| 93 | +cd test |
| 94 | +npm install |
| 95 | +npm test |
| 96 | +``` |
| 97 | + |
| 98 | +The test suite includes: |
| 99 | + |
| 100 | +- Snapshot testing for output verification |
| 101 | +- Various input scenarios validation |
| 102 | +- Error condition testing |
| 103 | + |
| 104 | +### Test Configuration |
| 105 | + |
| 106 | +Tests are configured in `test/tui-test.config.js` and test cases are defined in `test/sumcli.test.js`. |
| 107 | + |
| 108 | +## Development |
| 109 | + |
| 110 | +### Project Structure |
| 111 | + |
| 112 | +``` |
| 113 | +poc_for_testing_cli_app/ |
| 114 | +├── main.c # Main source code |
| 115 | +├── CMakeLists.txt # Build configuration |
| 116 | +├── test/ # Test directory |
| 117 | +│ ├── sumcli.test.js # Test cases |
| 118 | +│ ├── tui-test.config.js # Test configuration |
| 119 | +├── .github/workflows/ # CI/CD configuration |
| 120 | +└── README.md # This file |
| 121 | +``` |
| 122 | + |
| 123 | +### Contributing |
| 124 | + |
| 125 | +1. Fork the repository |
| 126 | +2. Create a feature branch |
| 127 | +3. Make your changes |
| 128 | +4. Run tests to ensure they pass |
| 129 | +5. Submit a pull request |
| 130 | + |
| 131 | +## CI/CD |
| 132 | + |
| 133 | +The project includes GitHub Actions workflow for: |
| 134 | + |
| 135 | +- Automated compliance checks |
| 136 | +- Build verification |
| 137 | +- Test execution |
| 138 | + |
| 139 | +## License |
| 140 | + |
| 141 | +See `LICENSE.txt` for license information. |
| 142 | + |
| 143 | +## Requirements |
| 144 | + |
| 145 | +- C99 compatible compiler |
| 146 | +- Standard C library |
| 147 | +- CMake 3.0 or higher (for building) |
| 148 | +- Node.js 16+ (for testing) |
0 commit comments