Commit 0eff71a
committed
Merge #49: Add template subcommand for create command
48dd8a0 fix: resolve clippy linting warnings (copilot-swe-agent[bot])
6e19205 style: apply rustfmt formatting (copilot-swe-agent[bot])
f277803 feat: [#41] add template subcommand for create command (copilot-swe-agent[bot])
2fe4bf1 Initial plan (copilot-swe-agent[bot])
Pull request description:
## Implementation Complete: Template Generation CLI Support (Issue #41)
This PR implements the `template` subcommand for the create command, allowing users to generate configuration file templates via the CLI.
### Implementation Checklist ✅
- [x] Update CLI command structure to support `create` subcommands (environment/template)
- [x] Add `CreateAction` enum with `Environment` and `Template` variants
- [x] Implement `handle_template_generation()` handler that calls domain method
- [x] Add user-friendly success messages with next steps
- [x] Update command routing to handle new subcommand structure
- [x] Add unit tests for CLI argument parsing
- [x] Add integration tests for template generation via CLI
- [x] Update CLI module tests to reflect new command structure
- [x] Manual testing of CLI commands
- [x] Linting and formatting (clippy and rustfmt)
- [x] Code review (passed with no comments)
- [x] Fix clippy pedantic warnings
### Security Summary
**No new security vulnerabilities introduced.**
This implementation is a thin CLI wrapper that:
- Delegates to existing domain method `EnvironmentCreationConfig::generate_template_file()`
- Uses standard async runtime for file operations
- Properly propagates domain-layer errors with `.help()` methods
- Creates parent directories safely using `tokio::fs::create_dir_all()`
- Writes files safely using `tokio::fs::write()`
The security posture is maintained by:
- No raw file operations - delegates to tokio's safe async file APIs
- No user input validation required (paths are already validated)
- Error handling includes proper context and actionable guidance
- No secrets or sensitive data in template generation
### Test Results
- **971 tests pass** (4 new template tests + 967 existing)
- **Clippy**: ✅ No warnings (all pedantic lints pass)
- **Rustfmt**: All code formatted
- **Manual testing**: All CLI commands work as expected
### CLI Usage Examples
```bash
# Generate template with default path
$ torrust-tracker-deployer create template
⏳ Generating configuration template...
✅ Configuration template generated: environment-template.json
# Generate template with custom path
$ torrust-tracker-deployer create template ./config/my-env.json
✅ Configuration template generated: ./config/my-env.json
# Create environment from config
$ torrust-tracker-deployer create environment --env-file config.json
```
### Closes
- Issue #41
<!-- START COPILOT CODING AGENT SUFFIX -->
<details>
<summary>Original prompt</summary>
----
*This section details on the original issue you should resolve*
<issue_title>[Subissue 7/7] Template Generation Support (Optional)</issue_title>
<issue_description>**Parent Epic**: #34 - Implement Create Environment Command
**Depends On**: #40 - Template System Integration
**Status**: OPTIONAL ENHANCEMENT
**Estimated Time**: 1-2 hours
> File tree
9 files changed
+461
-69
lines changed- src/presentation
- cli
- commands
- create
- tests
9 files changed
+461
-69
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
16 | | - | |
| 16 | + | |
17 | 17 | | |
18 | | - | |
19 | | - | |
20 | | - | |
| 18 | + | |
| 19 | + | |
21 | 20 | | |
22 | | - | |
23 | | - | |
24 | | - | |
25 | | - | |
26 | | - | |
27 | | - | |
28 | | - | |
| 21 | + | |
| 22 | + | |
29 | 23 | | |
30 | 24 | | |
31 | 25 | | |
| |||
65 | 59 | | |
66 | 60 | | |
67 | 61 | | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
14 | | - | |
| 14 | + | |
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| |||
168 | 168 | | |
169 | 169 | | |
170 | 170 | | |
171 | | - | |
| 171 | + | |
172 | 172 | | |
173 | 173 | | |
174 | 174 | | |
| 175 | + | |
175 | 176 | | |
176 | 177 | | |
177 | 178 | | |
178 | 179 | | |
179 | 180 | | |
180 | 181 | | |
181 | 182 | | |
182 | | - | |
183 | | - | |
184 | | - | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
185 | 191 | | |
186 | 192 | | |
187 | 193 | | |
188 | 194 | | |
189 | 195 | | |
190 | | - | |
191 | | - | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
192 | 204 | | |
193 | 205 | | |
194 | 206 | | |
195 | | - | |
196 | | - | |
197 | | - | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
198 | 215 | | |
199 | 216 | | |
200 | 217 | | |
201 | 218 | | |
202 | 219 | | |
203 | | - | |
204 | | - | |
| 220 | + | |
| 221 | + | |
205 | 222 | | |
206 | 223 | | |
207 | 224 | | |
| |||
214 | 231 | | |
215 | 232 | | |
216 | 233 | | |
217 | | - | |
| 234 | + | |
218 | 235 | | |
219 | 236 | | |
220 | 237 | | |
221 | 238 | | |
222 | 239 | | |
| 240 | + | |
223 | 241 | | |
224 | 242 | | |
225 | 243 | | |
| |||
231 | 249 | | |
232 | 250 | | |
233 | 251 | | |
234 | | - | |
235 | | - | |
236 | | - | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
237 | 260 | | |
238 | 261 | | |
239 | 262 | | |
240 | 263 | | |
241 | 264 | | |
242 | 265 | | |
243 | | - | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
244 | 273 | | |
245 | 274 | | |
246 | 275 | | |
| |||
255 | 284 | | |
256 | 285 | | |
257 | 286 | | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
258 | 352 | | |
259 | 353 | | |
260 | 354 | | |
261 | 355 | | |
262 | 356 | | |
263 | 357 | | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
264 | 374 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
65 | 65 | | |
66 | 66 | | |
67 | 67 | | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
68 | 76 | | |
69 | 77 | | |
70 | 78 | | |
| |||
100 | 108 | | |
101 | 109 | | |
102 | 110 | | |
103 | | - | |
| 111 | + | |
104 | 112 | | |
105 | 113 | | |
106 | 114 | | |
| |||
142 | 150 | | |
143 | 151 | | |
144 | 152 | | |
145 | | - | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
146 | 156 | | |
147 | 157 | | |
148 | 158 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
45 | | - | |
| 45 | + | |
0 commit comments