#20 (Feature: Interactive Book Selection --select)
What to build
Replace the select_mode stub in sync_run.py (currently prints "not yet implemented" and returns) with the real selection pipeline. When select_mode=True, after filtering already-downloaded books and before the download loop:
TTY check — if sys.stdout.isatty() is False, print an error message ("--select requires an interactive terminal") and return SyncRunResult(fatal_error=...). Exit code 1 via cli.py. This prevents cron/non-interactive hangs (user story 7).
All caught up — if no undownloaded books remain, print "All caught up!" and exit 0 (identical to current behavior, user story 9).
Convert to Books — convert the filtered raw dicts to Book objects using from_library_row() from book.py.
Call selector — selector.select_books(books). If it returns an empty list, exit 0 (user story 10).
Pass to orchestrator — convert selected Book objects back to a format the orchestrator accepts, or pass them directly. The orchestrator currently takes list[dict] and calls from_library_row() internally, so selected Books need to flow through without double-conversion. The cleanest approach: pass selected Books as a list and skip the orchestrator's internal from_library_row conversion when Book objects are already provided (or convert Books back to raw dicts for compatibility).
--limit superseded — when select_mode is True, --limit is explicitly ignored (not applied). Print a verbose-mode note: "Selection mode active — --limit is superseded by manual selection." (user story 13)
Default off, no config option — --select is off by default and has no config.yaml key. Existing scripts and cron jobs are completely unaffected (user story 12).
Integration tests should cover: no-TTY error exit, all-caught-up path with select mode, empty selection exit 0, selected books flow correctly to the orchestrator/download function, --limit ignored when select is active.
Acceptance criteria
select_mode stub in sync_run.py replaced with real pipeline
No TTY → SyncRunResult(fatal_error=...) with clear error message
All-caught-up path works identically with and without --select
from_library_row() converts filtered raw dicts to Books before calling select_books()
Empty selection from select_books() → clean exit 0
Selected Books flow into the download orchestrator correctly (no double-conversion)
--limit is ignored when --select is active, with verbose note
--select has no config.yaml option — CLI-only, off by default
--select flag in argparse no longer says "[not implemented]"
## Parent
#20 (Feature: Interactive Book Selection `--select`)
## What to build
Replace the `select_mode` stub in `sync_run.py` (currently prints "not yet implemented" and returns) with the real selection pipeline. When `select_mode=True`, after filtering already-downloaded books and before the download loop:
1. **TTY check** — if `sys.stdout.isatty()` is False, print an error message ("--select requires an interactive terminal") and return `SyncRunResult(fatal_error=...)`. Exit code 1 via cli.py. This prevents cron/non-interactive hangs (user story 7).
2. **All caught up** — if no undownloaded books remain, print "All caught up!" and exit 0 (identical to current behavior, user story 9).
3. **Convert to Books** — convert the filtered raw dicts to `Book` objects using `from_library_row()` from `book.py`.
4. **Call selector** — `selector.select_books(books)`. If it returns an empty list, exit 0 (user story 10).
5. **Pass to orchestrator** — convert selected `Book` objects back to a format the orchestrator accepts, or pass them directly. The orchestrator currently takes `list[dict]` and calls `from_library_row()` internally, so selected Books need to flow through without double-conversion. The cleanest approach: pass selected Books as a list and skip the orchestrator's internal `from_library_row` conversion when Book objects are already provided (or convert Books back to raw dicts for compatibility).
6. **`--limit` superseded** — when `select_mode` is True, `--limit` is explicitly ignored (not applied). Print a verbose-mode note: "Selection mode active — --limit is superseded by manual selection." (user story 13)
7. **Default off, no config option** — `--select` is off by default and has no `config.yaml` key. Existing scripts and cron jobs are completely unaffected (user story 12).
Integration tests should cover: no-TTY error exit, all-caught-up path with select mode, empty selection exit 0, selected books flow correctly to the orchestrator/download function, `--limit` ignored when select is active.
## Acceptance criteria
- [ ] `select_mode` stub in `sync_run.py` replaced with real pipeline
- [ ] No TTY → `SyncRunResult(fatal_error=...)` with clear error message
- [ ] All-caught-up path works identically with and without `--select`
- [ ] `from_library_row()` converts filtered raw dicts to Books before calling `select_books()`
- [ ] Empty selection from `select_books()` → clean exit 0
- [ ] Selected Books flow into the download orchestrator correctly (no double-conversion)
- [ ] `--limit` is ignored when `--select` is active, with verbose note
- [ ] `--select` has no config.yaml option — CLI-only, off by default
- [ ] `--select` flag in argparse no longer says "[not implemented]"
- [ ] Integration tests in `test_sync_run.py` cover: no-TTY error, all-caught-up, empty selection, selected→orchestrator flow, limit-ignored
- [ ] Existing tests continue to pass (no regressions)
## Blocked by
- #47 (Slice 1: selector.py module)
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Parent
#20 (Feature: Interactive Book Selection
--select)What to build
Replace the
select_modestub insync_run.py(currently prints "not yet implemented" and returns) with the real selection pipeline. Whenselect_mode=True, after filtering already-downloaded books and before the download loop:TTY check — if
sys.stdout.isatty()is False, print an error message ("--select requires an interactive terminal") and returnSyncRunResult(fatal_error=...). Exit code 1 via cli.py. This prevents cron/non-interactive hangs (user story 7).All caught up — if no undownloaded books remain, print "All caught up!" and exit 0 (identical to current behavior, user story 9).
Convert to Books — convert the filtered raw dicts to
Bookobjects usingfrom_library_row()frombook.py.Call selector —
selector.select_books(books). If it returns an empty list, exit 0 (user story 10).Pass to orchestrator — convert selected
Bookobjects back to a format the orchestrator accepts, or pass them directly. The orchestrator currently takeslist[dict]and callsfrom_library_row()internally, so selected Books need to flow through without double-conversion. The cleanest approach: pass selected Books as a list and skip the orchestrator's internalfrom_library_rowconversion when Book objects are already provided (or convert Books back to raw dicts for compatibility).--limitsuperseded — whenselect_modeis True,--limitis explicitly ignored (not applied). Print a verbose-mode note: "Selection mode active — --limit is superseded by manual selection." (user story 13)Default off, no config option —
--selectis off by default and has noconfig.yamlkey. Existing scripts and cron jobs are completely unaffected (user story 12).Integration tests should cover: no-TTY error exit, all-caught-up path with select mode, empty selection exit 0, selected books flow correctly to the orchestrator/download function,
--limitignored when select is active.Acceptance criteria
select_modestub insync_run.pyreplaced with real pipelineSyncRunResult(fatal_error=...)with clear error message--selectfrom_library_row()converts filtered raw dicts to Books before callingselect_books()select_books()→ clean exit 0--limitis ignored when--selectis active, with verbose note--selecthas no config.yaml option — CLI-only, off by default--selectflag in argparse no longer says "[not implemented]"test_sync_run.pycover: no-TTY error, all-caught-up, empty selection, selected→orchestrator flow, limit-ignoredBlocked by
Implemented in
fa1543e. All 11 acceptance criteria met, 304 tests pass with 0 regressions.