Skip to content

Change BookShelves.Shelf to Return (*Shelf, bool) and Remove StructIsEmpty - #28

Merged
polymorcodeus merged 2 commits into
mainfrom
shelf-api
Sep 9, 2026
Merged

polymorcodeus merged 2 commits into
mainfrom
shelf-api

Conversation

@polymorcodeus

Copy link
Copy Markdown
Owner

Summary

Changes the BookShelves.Shelf lookup API from a zero-value sentinel to an explicit (*Shelf, bool) return, deletes the reflection-based StructIsEmpty helper, and updates every caller across cmd/book and internal/model. Also fixes the delete completed view and scrubs the legacy polybook name from CONTRIBUTING.md.

What's new

  • Explicit shelf lookup API - BookShelves.Shelf(name) now returns (*Shelf, bool), matching the existing Shelf.Collection nil-on-miss pattern.
  • Removal of StructIsEmpty - deletes the reflection helper and its test; callers now rely on the boolean or nil checks.
  • TUI selection flow fix - markRootScreen passes nil for get/edit/delete, and GetMarkForm shows/hides the mark picker by action, preventing the nil-mark panic in interactive flows.
  • Delete success view - ResultView now renders the removed mark instead of the whole collection.
  • Docs cleanup - replaces polybook with book in CONTRIBUTING.md.

Behavior changes / guardrails

  • A missing shelf now returns (nil, false) instead of &Shelf{}; all production callers have been updated to check the boolean.
  • The mark picker is shown for book mark get/edit/remove and hidden for add/list.
  • markRootScreen no longer materializes an empty book.Mark; it passes the provided pointer through.
  • Delete success output now displays the mark title, URL, and tags rather than the collection's mark list.

Testing

  • Added TestBookShelvesShelf covering found and missing shelf lookups.
  • Updated cmd/book/actions_test.go to use a testShelf helper that asserts the ok return.
  • make check runs fmt, vet, lint, and tests; all green.

@polymorcodeus
polymorcodeus merged commit 5a60d39 into main Sep 9, 2026
4 checks passed
@polymorcodeus
polymorcodeus deleted the shelf-api branch September 9, 2026 17:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant