V0.4.0 #14

Merged
umpire274 merged 4 commits from v0.4.0 into main 2025-10-20 16:09:07 +02:00
umpire274 commented 2025-10-20 16:03:40 +02:00 (Migrated from github.com)

[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").
## [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"`).
Sign in to join this conversation.
No description provided.