Skip to content

Conversation

@umpire274
Copy link
Owner

[0.4.0] - 2025-10-18

Added

  • New command add book:

    • Fetches book information automatically from the Google Books API using ISBN.
    • Populates title, author, editor, year, language, genre, and summary automatically.
    • Fallback to interactive mode (planned) for books not found.
  • New command edit book:

    • Allows updating any existing book record by ID or ISBN.
    • Supports all editable fields (title, author, editor, year, language, pages,
      genre, summary, room, shelf, row, position), excluding ID and ISBN.
    • Automatically converts language codes (e.g., "en" → "English") using lang_code_to_name().
    • Dynamically generates CLI arguments for each editable field via a centralized
      EDITABLE_FIELDS definition in fields.rs.
    • Grouped and ordered help output using display_order() and next_help_heading():
      • Global options appear first.
      • Book-specific options are clearly grouped under titled sections.
    • Field updates now display localized detailed messages:
      • e.g. ✅ Field "year" updated successfully (2018 → 2020).
      • Shows both the previous and new values for each modified field.
    • Final update summary message supports language-aware pluralization:
      • English: "✅ Book 9788820382698 successfully updated (2 fields modified)."
      • Italian: "✅ Libro 9788820382698 aggiornato correttamente (2 campi modificati)."
  • Integrated dynamic i18n support for all CLI help messages (add, edit, book, isbn).

  • Added automatic language name resolution (e.g., "it""Italian").

  • New utility module utils/lang.rs for ISO 639-1 to language name conversion.

  • New utility module utils/isbn.rs:

    • Introduced the normalize_isbn() helper for validation and bidirectional formatting.
    • Supports both ISBN-10 and ISBN-13 with hyphenation handling.
    • Returns localized error messages for invalid, undefined, or malformed ISBNs.
    • Includes comprehensive unit tests and doctests.
  • Localized console messages for book lookup, edition, and insertion results.

Changed

  • Modularized command structure: added add.rs, add_book.rs, and edit_book.rs under src/commands/.
  • Unified language handling logic between add and edit commands.
  • Improved error handling for Google Books API responses and JSON decoding.
  • Replaced manual impl Default blocks with idiomatic #[derive(Default)].
  • Enhanced ISBN display formatting in the list command using normalize_isbn() for readable hyphenated output.
  • Refactored CLI (cli.rs) with ordered, grouped, and localized help output for all commands.
  • Localized final book update message with plural-sensitive translation keys:
    • "edit.book.updated.one" and "edit.book.updated.many" in en.json / it.json.

Fixed

  • Deserialization issues with Google Books API fields (volumeInfo, publishedDate, pageCount).
  • Empty fields on insertion caused by incorrect field mapping.
  • Prevented duplicate ISBN insertion with user-friendly message ("Book already present in your library").

umpire274 and others added 4 commits October 18, 2025 00:33
…integration

Implemented new subcommand add book --isbn <ISBN> for automatic metadata retrieval.

Integrated Google Books API to fetch title, author, publisher, year, and language.

Added ISO 639-1 → full language name conversion utility.

Localized all messages and help texts (English / Italian).

Refactored Default trait derivations for cleaner structs.

Improved error handling and field mapping for API responses.
… output

- Introduced new utility module utils/isbn.rs with normalize_isbn() function.
- Added full ISBN-10 and ISBN-13 validation with bidirectional conversion.
- Implemented localized error messages via i18n for invalid ISBNs.
- Integrated ISBN normalization in the list command for readable formatting.
- Added comprehensive unit tests and doctests for the new helper.
- Finalized version 0.4.0 with new `edit book` command.
- Added dynamic field generation via `EDITABLE_FIELDS` and automatic language conversion.
- Introduced ordered and grouped CLI help using `display_order()` and `next_help_heading()`.
- Added localized detailed field update messages showing old → new values.
- Implemented plural-aware summary messages for all languages (e.g., "campo"/"campi").
- Refactored CLI structure for consistency, readability, and full i18n support.
@umpire274 umpire274 merged commit 1f89724 into main Oct 20, 2025
1 check passed
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.

2 participants