Commit 79cd8ea
committed
75af108 refactor: [#107] extract DestroyCommandController with private step methods (Jose Celano)
9730bd0 refactor: [#107] apply GitHub Copilot PR review suggestions (Jose Celano)
b49bcc0 refactor: [#107] simplify error handling with From trait for ProgressReporterError (Jose Celano)
cb10deb refactor: [#107] replace mutex panics with proper error handling (Jose Celano)
f0704ec refactor: [#107] extract test setup helper in factory module (Jose Celano)
b9212ac refactor: [#107] extract test setup helper to reduce duplication (Jose Celano)
38878bb refactor: [#107] remove unnecessary report_error wrapper function (Jose Celano)
d06f3ed refactor: [#107] eliminate duplicate CommandContext creation (Jose Celano)
c5de285 refactor: [#107] centralize UserOutput via dependency injection (Jose Celano)
Pull request description:
## Summary
This PR centralizes `UserOutput` management via dependency injection, providing better control over output formatting and reducing duplication throughout the codebase.
## Changes
### Core Changes
- ✅ Add `AppContainer` for centralized dependency management (`src/bootstrap/container.rs`)
- ✅ Update all command handlers to accept `&Arc<Mutex<UserOutput>>`
- ✅ Remove `UserOutput` cloning throughout command execution
- ✅ Ensure thread-safe shared ownership of output stream
### Documentation
- ✅ Update all documentation examples to use `Arc<Mutex<UserOutput>>`
- ✅ Fix all doc tests to compile with new API (234 passing)
### Testing
- ✅ Update all tests to use the new pattern
- ✅ All pre-commit checks passing
## Benefits
1. **Centralized Control**: Single point of creation for UserOutput
2. **Thread Safety**: Proper Arc<Mutex<>> wrapper ensures safe concurrent access
3. **Reduced Duplication**: Eliminates cloning throughout the codebase
4. **Better Testing**: Easier to inject mock outputs for testing
## Files Changed (20 files)
- `src/bootstrap/app.rs` - Updated to use AppContainer
- `src/bootstrap/container.rs` - **NEW** - Dependency injection container
- `src/bootstrap/mod.rs` - Module updates
- `src/presentation/commands/context.rs` - Updated API and docs
- `src/presentation/commands/create/*` - Updated create command handlers
- `src/presentation/commands/destroy/*` - Updated destroy command handlers
- `src/presentation/commands/factory.rs` - Updated factory methods
- `src/presentation/commands/mod.rs` - Updated command execution
- `src/presentation/progress.rs` - Updated progress reporting
- Tests updated across all command modules
## Status
- [x] All tests passing
- [x] Documentation updated
- [x] Pre-commit checks passing
- [x] Additional refactors planned (keeping as draft)
## Related
Closes #107
ACKs for top commit:
josecelano:
ACK 75af108
Tree-SHA512: eeeb255bbf2f30fae9f0f1b68a94ba9cae326c74a47476a747831500b1e918ef234a30a3bf0545a891cb3d8ee1579e371628f418175559c85acd35ed73e71c73
File tree
20 files changed
+1178
-417
lines changed- src
- bootstrap
- presentation
- commands
- create
- subcommands
- tests
- destroy
- tests
- tests
20 files changed
+1178
-417
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
30 | | - | |
31 | | - | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
32 | 33 | | |
33 | 34 | | |
34 | 35 | | |
| |||
54 | 55 | | |
55 | 56 | | |
56 | 57 | | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
57 | 61 | | |
58 | 62 | | |
59 | | - | |
60 | | - | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
61 | 67 | | |
62 | 68 | | |
63 | 69 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 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 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
4 | | - | |
| 4 | + | |
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| 9 | + | |
9 | 10 | | |
10 | 11 | | |
11 | 12 | | |
12 | 13 | | |
| 14 | + | |
13 | 15 | | |
14 | 16 | | |
15 | 17 | | |
16 | 18 | | |
| 19 | + | |
17 | 20 | | |
0 commit comments