Conversation
- 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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
[0.3.0] - 2025-10-16
Added
tabledcrate (v0.20.0) for tabular output.--shortflag forlibrius listshowing only key columns (ID, Title, Author, Editor, Year).build_table()inutils/table.rsto render tables with consistent style and alignment.--delimiter/-dforimportcommand.Allows specifying a custom CSV field separator (default:
,).Changed
listcommand to useBookFullandBookShortwrappers implementingTabled.commands,db,config,i18n,models,utils) now includes amod.rs.lib.rsfor cleaner module access.Refactored
utils::open_import_file()now handles file opening with localized error reporting.utils::handle_import_result()manages database insert results and counters.handle_import_csv()andhandle_import_json().Fixed
The
idfield in theBookstruct is now optional (Option<i32>),preventing missing-field errors during import when the ID column is not present.
Removed
println!formatting for book listings.