chore: Move all command handlers to their own files

This makes the code much easier to follow and shortens main.rs from
>1000 lines to around 150.
This commit is contained in:
2025-11-29 00:54:46 +01:00
parent 095e15cd5f
commit 5f54124015
19 changed files with 1057 additions and 918 deletions

View File

@@ -223,19 +223,46 @@ COMMANDS:
- Security audits for data handling
- Compatibility tests with existing configurations
### Phase 9: File-Based Source Adapters
### Phase 9.5: Command Handler Extraction ✅ COMPLETED
**Objective**: Extract command handling logic from main.rs into dedicated modules for better maintainability and separation of concerns.
**Steps:**
1. ✅ Create `commands/` module structure with submodules for each command group
2. ✅ Extract table printing utilities to `cli/tables.rs`
3. ✅ Move command handlers to appropriate modules:
- `commands/sync.rs`: Sync command logic
- `commands/accounts/`: Account management (link, list, status)
- `commands/transactions/`: Transaction operations (list, cache, clear)
- `commands/list.rs`: Source/destination listing
4. ✅ Update main.rs to dispatch to new command modules
5. ✅ Remove extracted functions from main.rs, reducing it from 1049 to ~150 lines
6. ✅ Update documentation to reflect new structure
**Implementation Details:**
- Created hierarchical module structure with focused responsibilities
- Maintained all existing functionality and CLI interface
- Improved code organization and testability
- Updated architecture documentation with new module structure
**Testing:**
- All existing tests pass
- CLI functionality preserved
- Code formatting and linting applied
### Phase 10: File-Based Source Adapters
**Objective**: Implement adapters for file-based transaction sources.
**Steps:**
1. Create `adapters::csv` module implementing `TransactionSource`
- Parse CSV files with configurable column mappings
- Implement caching similar to GoCardless adapter
- Add inspection methods for file status and transaction counts
- Parse CSV files with configurable column mappings
- Implement caching similar to GoCardless adapter
- Add inspection methods for file status and transaction counts
2. Create `adapters::camt053` and `adapters::mt940` modules
- Parse respective financial file formats
- Implement transaction mapping and validation
- Add format-specific caching and inspection
- Parse respective financial file formats
- Implement transaction mapping and validation
- Add format-specific caching and inspection
3. Update `adapter_factory` to instantiate file adapters with file paths
**Testing:**