#20 (Feature: Interactive Book Selection --select)
What to build
Add questionary as a required runtime dependency in pyproject.toml. Create a new librofm_downloader/selector.py module with a clean public interface: select_books(books: list[Book]) -> list[Book].
The function:
Formats each Book into a display string: "N. Title — First Author [Series #]" (series suffix omitted when absent, author falls back to "Unknown")
Opens a questionary checkbox prompt with those choices, all unchecked by default (opt-in — user story 4)
If the user selects zero books and presses Enter, prints "No books selected. Exiting." and returns an empty list
If the user selects one or more books, shows a confirmation summary: N book(s) selected for download: with a bulleted list, then prompts y/N
On confirmation (y/Y), returns the selected Book objects in their original input order (not the order checkboxes were toggled)
On cancellation (N / bare Enter / Ctrl+C at confirm), returns an empty list
Ctrl+C during the checkbox prompt itself propagates KeyboardInterrupt (handled upstream by sync_run)
Row format: N. Title — First Author [Series #]
N is 1-based index
[Series #] suffix only when both series and series_num are present
Duration excluded (per PRD — would require N extra API calls)
The module has no side effects beyond console I/O via questionary/Rich. It does not call any network APIs or touch the filesystem.
Unit test file: tests/test_selector.py. Tests should patch questionary prompt functions to return controlled values without rendering a real TUI. Test external behavior (inputs → outputs), not which questionary methods were called.
Acceptance criteria
questionary added to dependencies in pyproject.toml
selector.py exists with _format_row(book, index) -> str and select_books(books) -> list[Book]
_format_row produces correct output: with series, without series, single author, no authors → "Unknown"
select_books returns the correct subset of Books in original input order
select_books returns empty list on zero selection
select_books returns empty list on confirmation rejection (N / bare Enter)
select_books returns selected Books on confirmation acceptance (y/Y)
Ctrl+C during checkbox propagates as KeyboardInterrupt
All checkbox choices start unchecked by default
test_selector.py has unit tests covering: formatting variants, selection round-trip, empty selection, confirm yes, confirm no, order preservation, single-book library
Blocked by
None — can start immediately.
## Parent
#20 (Feature: Interactive Book Selection `--select`)
## What to build
Add `questionary` as a required runtime dependency in `pyproject.toml`. Create a new `librofm_downloader/selector.py` module with a clean public interface: `select_books(books: list[Book]) -> list[Book]`.
The function:
1. Formats each Book into a display string: `"N. Title — First Author [Series #]"` (series suffix omitted when absent, author falls back to "Unknown")
2. Opens a questionary checkbox prompt with those choices, **all unchecked by default** (opt-in — user story 4)
3. If the user selects zero books and presses Enter, prints "No books selected. Exiting." and returns an empty list
4. If the user selects one or more books, shows a confirmation summary: `N book(s) selected for download:` with a bulleted list, then prompts y/N
5. On confirmation (y/Y), returns the selected Book objects in their **original input order** (not the order checkboxes were toggled)
6. On cancellation (N / bare Enter / Ctrl+C at confirm), returns an empty list
7. Ctrl+C during the checkbox prompt itself propagates `KeyboardInterrupt` (handled upstream by sync_run)
Row format: `N. Title — First Author [Series #]`
- N is 1-based index
- `[Series #]` suffix only when both `series` and `series_num` are present
- Duration excluded (per PRD — would require N extra API calls)
The module has no side effects beyond console I/O via questionary/Rich. It does not call any network APIs or touch the filesystem.
Unit test file: `tests/test_selector.py`. Tests should patch questionary prompt functions to return controlled values without rendering a real TUI. Test external behavior (inputs → outputs), not which questionary methods were called.
## Acceptance criteria
- [ ] `questionary` added to `dependencies` in `pyproject.toml`
- [ ] `selector.py` exists with `_format_row(book, index) -> str` and `select_books(books) -> list[Book]`
- [ ] `_format_row` produces correct output: with series, without series, single author, no authors → "Unknown"
- [ ] `select_books` returns the correct subset of Books in original input order
- [ ] `select_books` returns empty list on zero selection
- [ ] `select_books` returns empty list on confirmation rejection (N / bare Enter)
- [ ] `select_books` returns selected Books on confirmation acceptance (y/Y)
- [ ] Ctrl+C during checkbox propagates as `KeyboardInterrupt`
- [ ] All checkbox choices start unchecked by default
- [ ] `test_selector.py` has unit tests covering: formatting variants, selection round-trip, empty selection, confirm yes, confirm no, order preservation, single-book library
## Blocked by
None — can start immediately.
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
Add
questionaryas a required runtime dependency inpyproject.toml. Create a newlibrofm_downloader/selector.pymodule with a clean public interface:select_books(books: list[Book]) -> list[Book].The function:
"N. Title — First Author [Series #]"(series suffix omitted when absent, author falls back to "Unknown")N book(s) selected for download:with a bulleted list, then prompts y/NKeyboardInterrupt(handled upstream by sync_run)Row format:
N. Title — First Author [Series #][Series #]suffix only when bothseriesandseries_numare presentThe module has no side effects beyond console I/O via questionary/Rich. It does not call any network APIs or touch the filesystem.
Unit test file:
tests/test_selector.py. Tests should patch questionary prompt functions to return controlled values without rendering a real TUI. Test external behavior (inputs → outputs), not which questionary methods were called.Acceptance criteria
questionaryadded todependenciesinpyproject.tomlselector.pyexists with_format_row(book, index) -> strandselect_books(books) -> list[Book]_format_rowproduces correct output: with series, without series, single author, no authors → "Unknown"select_booksreturns the correct subset of Books in original input orderselect_booksreturns empty list on zero selectionselect_booksreturns empty list on confirmation rejection (N / bare Enter)select_booksreturns selected Books on confirmation acceptance (y/Y)KeyboardInterrupttest_selector.pyhas unit tests covering: formatting variants, selection round-trip, empty selection, confirm yes, confirm no, order preservation, single-book libraryBlocked by
None — can start immediately.
Implemented in
922e7feonfeature/chooseBooks.