Skip to content

Conversation

@umpire274
Copy link
Owner

[0.3.0] - 2025-10-16

Added

  • Introduced the tabled crate (v0.20.0) for tabular output.
  • New --short flag for librius list showing only key columns (ID, Title, Author, Editor, Year).
  • New utility build_table() in utils/table.rs to render tables with consistent style and alignment.
  • CLI option --delimiter / -d for import command.
    Allows specifying a custom CSV field separator (default: ,).

Changed

  • Refactored list command to use BookFull and BookShort wrappers implementing Tabled.
  • Standardized module structure across the project:
    • Each main directory (commands, db, config, i18n, models, utils) now includes a mod.rs.
    • Unified import/export logic in lib.rs for cleaner module access.
  • Improved code readability, organization, and adherence to Rust idioms.

Refactored

  • Extracted duplicated import logic into reusable helper functions:
    • utils::open_import_file() now handles file opening with localized error reporting.
    • utils::handle_import_result() manages database insert results and counters.
  • Unified behavior between handle_import_csv() and handle_import_json().
  • Simplified error handling and improved localization consistency across import operations.
  • Reduced code duplication and improved maintainability throughout the import module.

Fixed

  • CSV/JSON import deserialization error:
    The id field in the Book struct is now optional (Option<i32>),
    preventing missing-field errors during import when the ID column is not present.

Removed

  • Legacy manual println! formatting for book listings.

umpire274 and others added 5 commits October 16, 2025 17:24
- Replaced manual list formatting with `tabled` (v0.20.0) for modern, aligned tabular output.
- Added `--short` flag to display compact view (ID, Title, Author, Editor, Year).
- Implemented reusable `build_table()` helper under `utils::table` for consistent CLI formatting.
- Standardized module structure:
  - Added `mod.rs` to all submodules (commands, models, utils, db, config, i18n).
  - Simplified imports using `pub use` re-exports in `lib.rs`.
- Improved code organization and idiomatic Rust layout.
…ake Book.id optional

- Added CLI parameter --delimiter / -d to specify custom CSV field separator (default ',')
- Refactored import logic for CSV and JSON:
  - utils::open_import_file() now handles file opening with localized error handling
  - utils::handle_import_result() manages DB insert results and counters
- Made Book.id optional (Option<i32>) to fix CSV/JSON import deserialization errors
- Unified error reporting, localization, and counters across import commands
- Improved code maintainability and removed duplication
- Introduced two new CLI options to the `list` command:
  - `--id <ID>`: display a specific book record by its ID.
  - `--details`: show all fields of the specified record in a vertical table.
- If only `--id` is provided, details are shown automatically.
- If `--details` is used without `--id`, an error message is displayed.
- Implemented dynamic `build_vertical_table()` using `serde_json` + `tabled`
  to automatically render all struct fields without manual updates.
- Updated command builder and `handle_list()` logic accordingly.

refactor(list): unify query_map and own SQL params

- Extract a dedicated row_to_book helper to centralize mapping from rusqlite::Row to Book.
- Replace duplicated query_map closures with a single parameterized call that uses owned SQL parameters (Vec<Box<dyn ToSql>>) to ensure parameter lifetimes.
- Remove redundant closures and needless borrows (pass functions directly where appropriate).
- Add validation so --details must be used together with --id, and add localized messages for this case (EN/IT).
- Fix Clippy warnings and verify build & tests.
## [0.3.0] - 2025-10-16

### Added
- Introduced the `tabled` crate (`v0.20.0`) for consistent tabular output.
- New `--short` flag for `librius list` showing only key columns (ID, Title, Author, Editor, Year).
- Added utility `build_table()` in `utils/table.rs` to render tables with unified style and alignment.
- Added `--delimiter` / `-d` option for the `import` command to specify custom CSV field separators (default: `,`).

### Changed
- Refactored the `list` command to use `BookFull` and `BookShort` wrappers implementing `Tabled`.
- Standardized the internal module structure:
  - Each main directory (`commands`, `db`, `config`, `i18n`, `models`, `utils`) now includes a `mod.rs`.
  - Unified import/export logic in `lib.rs` for cleaner module access.
- Improved code readability and CLI consistency.
@umpire274 umpire274 merged commit fc04b06 into main Oct 16, 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