refactor(cli): extract sync_run pipeline and slim CLI to adapter (#31)

Move entire download pipeline from cli.run() into standalone
sync_run() in new sync_run.py module. Introduce SyncRunResult
frozen dataclass as public return type with fatal_error field
for exit-code translation. Slim cli.py from 252→65 lines to a
thin argparse→exit adapter that only calls sync_run().

Migrate 35 pipeline tests from test_cli.py to test_sync_run.py
(43 total). CLI tests now only patch sync_run (no internal
collaborators). Add select_mode stub for ADR #6 branch point.
Update test_progress.py patch targets to sync_run module.
374 tests pass.
This commit is contained in:
AlexKucera committed 2026-06-05 14:52:00 +02:00
1 parent 1f46467f2c
commit f371152166
8 files changed
+2145 -1651

No files matched your search

+10 -1
View File
@@ -34,7 +34,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
directly. download_book() accepts optional progress= kwarg. Public
update() drops task_id param. 382 tests pass (+11 new). Closes #30.
10:9bb|### Fixed
- **cli/sync-run:** Extract entire download pipeline from cli.run() into
standalone sync_run() function in new sync_run.py module. Introduce
SyncRunResult frozen dataclass (replaces OrchestratorResult as public
return type). Slim cli.py from 252→65 lines to a thin argparse→exit
adapter that only patches sync_run(). Migrate 35 pipeline tests from
test_cli.py to test_sync_run.py (43 total + 10 CLI-only tests).
Add select_mode stub (ADR #6 branch point) and fatal_error field for
exit-code translation. 374 tests pass. Closes #31.
### Fixed
- **progress:** Wire task_id through parallel progress callback.
All concurrent download updates went to the same (most recently started) bar
because `task_id` was never threaded from `start_download()` to `update()`.