You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/contributing/module-organization.md
+143Lines changed: 143 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -449,6 +449,149 @@ These guidelines are general principles, not absolute rules. Consider deviating
449
449
450
450
Use your judgment, but **always prioritize readability and maintainability**.
451
451
452
+
## 📂 Command Module Structure Patterns
453
+
454
+
For presentation layer commands in `src/presentation/commands/`, we follow standardized folder structures that make it clear whether a command has subcommands or is a simple single-purpose command.
455
+
456
+
### Pattern 1: Simple Commands (No Subcommands)
457
+
458
+
For commands that perform a single operation (like `destroy`):
459
+
460
+
```
461
+
src/presentation/commands/destroy/
462
+
├── mod.rs // Module documentation and re-exports
463
+
├── handler.rs // Main command implementation
464
+
├── errors.rs // Error types
465
+
└── tests/ // Test modules
466
+
├── mod.rs
467
+
└── integration.rs
468
+
```
469
+
470
+
**Key characteristics:**
471
+
- Uses `handler.rs` for the main command logic
472
+
- Direct implementation without routing
473
+
- Clean and focused on single responsibility
474
+
475
+
**Example:**
476
+
```rust
477
+
// In handler.rs
478
+
pubfnhandle_destroy_command(
479
+
environment_name:&str,
480
+
working_dir:&Path,
481
+
) ->Result<(), DestroySubcommandError> {
482
+
// Direct implementation
483
+
}
484
+
```
485
+
486
+
### Pattern 2: Commands with Subcommands
487
+
488
+
For commands that route to multiple subcommands (like `create`):
489
+
490
+
```
491
+
src/presentation/commands/create/
492
+
├── mod.rs // Module documentation and re-exports
493
+
├── handler.rs // Router that delegates to subcommands
0 commit comments