All notable changes to this project will be documented in this file.
This release introduces a full internal refactor of the codebase. No user-facing behaviour is changed; all commands, flags and output remain identical.
utils/verbose.rs—VERBOSEstatic,set_verbose(),is_verbose()utils/print.rs—iconsmodule (OK/ERR/WARN/INFO) +print_ok/err/warn/info()utils/log.rs—now_str(),write_log()(structured SQLite log entries)utils/import_helpers.rs—open_import_file(),handle_import_result()utils/mod.rs— aggregator with explicitpub useonly (no more glob re-exports)
cli/fields.rs—EDITABLE_FIELDSmoved fromutils/(it is a CLI concern, not a generic utility)cli/mod.rs— removed deadCommandsenum (only 3 of 8 commands were represented, never used by dispatch)
models/book.rs— pure data model:Bookstruct +from_row()+ Serde only; notabled/i18ndependenciesmodels/display.rs(new) —BookFull,BookShortwithTabledimplementations and localised column headers
db/load_db.rs→db/connection.rs— clearer name for DB connection managementdb/migrate_db.rs→db/migrations.rs— clearer name for migration logicdb/search.rs— absorbed intodb/books.rs;search_books()belongs with book operations
commands/add.rsremoved — 18-line wrapper that only calledhandle_add_book()directly (dead code)commands/list.rs—row_to_book()simplified to delegate toBook::from_row()+ ISBN formatting onlycommands/db.rs— localcreate_schema()duplicate removed; delegates todb::connection::ensure_schema()commands/config.rs—handle_config()signature changed from&Commandsenum to explicit bool parameters(init, print, edit, editor)
- Removed all wildcard re-exports (
pub use commands::*,pub use utils::*, etc.) - Replaced with an explicit, minimal public API:
pub use config::{AppConfig, load_or_init}; pub use db::{init_db, start_db}; pub use models::Book; pub use i18n::{load_language, tr, tr_s, tr_with};
- All internal modules now use full
crate::x::yimport paths
run_migrations()was called twice (once instart_db(), once explicitly inmain). Removed the redundant call inmain.rs.
- Added
STRUCTURE.md— complete map of every source file with its single responsibility, design rules table, and the explicit public API surface.
- New
dbcommand for database management:librius db --init→ initializes a new database (or resets the existing one).librius db --reset→ alias of--init, provided for clarity.librius db --copy -f <FILE>→ copies the current database (as defined inconfig.database) to a new file.
- Automatic use of the database path from the configuration file (
database:key inlibrius.yaml). - Added localized messages and colored output for database operations.
- New
--compactflag forlist --id <ID> --details:- Hides empty or null fields in the vertical table view.
- Useful for cleaner, shorter output when many fields are unused.
- The
--compactflag inlistis now dependent on--details.- Using
--compactwithout--detailswill result in an error message. - This ensures consistent CLI behavior and prevents meaningless flag combinations.
- Using
- CLI parsing for
--copynow correctly behaves as a flag (no value required). - Improved integration between configuration and database initialization routines.
- Corrected vertical table rendering (
list --id <ID> --details):- Proper localized headers (“Field” / “Value”) are now displayed.
- Columns now follow the database schema order instead of alphabetical order.
- Improved compatibility with existing
tabledcrate version.
This version introduces a simple and safe way to initialize, reset, or back up your Librius database directly from the command line.
- Introduced a complete automated test suite covering both database and CLI layers.
- Implemented
setup_temp_db()utility for creating temporary SQLite databases in the system temp directory:- Windows →
%TEMP%\librius_test_*.db - macOS / Linux →
/tmp/librius_test_*.db
- Windows →
- Added unit tests for database insert and search operations.
- Added integration tests for:
- CLI commands (
--help,search, etc.) usingassert_cmdandpredicates. - Database schema and consistency validation.
- ISBN normalization and formatting.
- CLI commands (
- All tests now use the real production schema for reliable, cross-platform testing.
- Performed a modular refactor of the CLI (
cli.rs→cli/directory):- Split the monolithic
cli.rsinto three logical units:args.rs— defines the full command tree and global flags.dispatch.rs— routes parsed commands to their handlers.mod.rs— re-exports and integrates the CLI components.
- Improved code readability, testability, and long-term maintainability.
- Prepared CLI for future integration with the
librius_corecrate and the GUI frontend.
- Split the monolithic
- Simplified the internal command dispatch logic and aligned display order for consistent help output.
- Removed obsolete in-source test modules (
#[cfg(test)]) from production files. - Eliminated build and Clippy warnings by conditionally compiling test-only code.
- Verified complete cross-platform compatibility (Windows, macOS, Linux).
- Established the foundation for multi-platform CI testing planned for
v0.5.1.
-
Reorganized command index in the CLI help output for better logical grouping and readability.
Commands are now displayed in a clearer order, following a structured hierarchy (Book commands, App commands, etc.). -
Localized help section titles (
help_heading) across the entire CLI, including:- “Global options”
- “List-specific options”
- “Import-specific options”
- “Export-specific options”
- and other command-related help blocks
-
Improved overall consistency and clarity of command descriptions and section headings in both English and Italian.
- Updated
display_ordervalues to reflect the new command hierarchy. - Refined
cli.rslayout for easier maintenance of localized help headings.
- 🔍 New
searchcommand- Allows searching books by title, author, editor, genre, or language.
- Usage:
librius search "dune" librius search "frank herbert" --short
- Supports both full (
BookFull) and compact (BookShort) table views. - Integrated with i18n for localized output messages and help text.
- Unified search output with
print_info,print_ok, andprint_warnfor consistent message style. - Renamed
commands/search.rs→commands/search_book.rsto avoid ambiguous glob re-exports. - Refactored
search_books()indb/search.rsto remove redundant closure for Clippy compliance.
- New
delcommand- Allows deletion of books by ID or ISBN with hybrid detection.
- Added interactive confirmation prompt to prevent accidental deletions.
- Introduced
--forceflag to skip confirmation in automated workflows. - Integrated with
write_log()to record all deletions (forced or confirmed).
- Localized all messages and help text for English and Italian.
- Updated CLI documentation and help output to include the new command.
# Interactive mode
$ librius del 129
Sei sicuro di voler eliminare il libro 129? [y/N]: y
✅ Libro 129 eliminato correttamente.
# Forced mode
$ librius del 9788820382698 --force
✅ Book 9788820382698 deleted successfully.- Minor cleanup in CLI argument ordering and localized help strings.
- Improved developer workflow consistency in the tools/ directory.
- All deletions are now logged via write_log() for audit and traceability.
- Added developer scripts in /tools for build and submodule checks.
- Updated private submodule tools_private to latest revision.
-
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") usinglang_code_to_name(). - Dynamically generates CLI arguments for each editable field via a centralized
EDITABLE_FIELDSdefinition infields.rs. - Grouped and ordered help output using
display_order()andnext_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.
- e.g.
- Final update summary message supports language-aware pluralization:
- English:
"✅ Book 9788820382698 successfully updated (2 fields modified)." - Italian:
"✅ Libro 9788820382698 aggiornato correttamente (2 campi modificati)."
- English:
-
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.rsfor 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.
- Introduced the
-
Localized console messages for book lookup, edition, and insertion results.
- Modularized command structure: added
add.rs,add_book.rs, andedit_book.rsundersrc/commands/. - Unified language handling logic between
addandeditcommands. - Improved error handling for Google Books API responses and JSON decoding.
- Replaced manual
impl Defaultblocks with idiomatic#[derive(Default)]. - Enhanced ISBN display formatting in the
listcommand usingnormalize_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"inen.json/it.json.
- 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").
# ➕ Add a new book automatically using its ISBN
$ librius add book --isbn 9788820382698
🔍 Searching for book with ISBN: 9788820382698
📘 Found: “La lingua dell'antico Egitto” — Emanuele M. Ciampini (2018)
✅ Book “La lingua dell'antico Egitto” successfully added to your library.
# 📚 List all books (compact view)
$ librius list --short
📚 Your Library
┌─────┬──────────────────────────────┬──────────────────────┬──────────────────────────────────────────────────────┬──────┬───────────────────┐
│ ID │ Title │ Author │ Editor │ Year │ ISBN │
├─────┼──────────────────────────────┼──────────────────────┼──────────────────────────────────────────────────────┼──────┼───────────────────┤
│ 91 │ The Hobbit │ J.R.R. Tolkien │ Allen & Unwin │ 1937 │ 978-0-345-33968-3 │
│ 92 │ Foundation │ Isaac Asimov │ Gnome Press │ 1951 │ 978-0-553-80371-0 │
│128 │ La lingua dell'antico Egitto │ Emanuele M. Ciampini │ Lingue antiche del Vicino Oriente e del Mediterraneo │ 2018 │ 978-88-203-8269-8 │
└─────┴──────────────────────────────┴──────────────────────┴──────────────────────────────────────────────────────┴──────┴───────────────────┘
# ✏️ Edit an existing record (by ISBN or ID)
$ librius edit book 9788820382698 --year 2020
📝 Updating book with ISBN 9788820382698...
✅ Field “year” updated successfully (2018 → 2020)
# 🌍 Update language using ISO code (automatically converted)
$ librius edit book 9788820382698 --lang_book en
📝 Updating book language...
✅ Field “language” updated successfully (“Italian” → “English”)
# 📖 Display detailed information
$ librius list --id 128 --details
📘 Book Details (ID 128)
────────────────────────────────────────────────────────────────────────────
Title: La lingua dell'antico Egitto
Author: Emanuele M. Ciampini
Editor: Lingue antiche del Vicino Oriente e del Mediterraneo
Year: 2020
Language: English
Genre: Linguistics
Pages: 432
Room: B
Shelf: 4
Row: 2
Position: 5
ISBN: 978-88-203-8269-8
────────────────────────────────────────────────────────────────────────────- Introduced official Librius icon and branding assets
- Added
librius.svg,librius.png, andlibrius.icoinres/ - Included build integration for Windows executables
- Added
- Prepared cross-platform structure for future GUI integration
- Updated documentation and README with new logo and asset references
- Introduced the
tabledcrate (v0.20.0) for tabular output. - New
--shortflag forlibrius listshowing only key columns (ID, Title, Author, Editor, Year). - New utility
build_table()inutils/table.rsto render tables with consistent style and alignment. - CLI option
--delimiter/-dforimportcommand.
Allows specifying a custom CSV field separator (default:,).
- Refactored
listcommand to useBookFullandBookShortwrappers implementingTabled. - Standardized module structure across the project:
- Each main directory (
commands,db,config,i18n,models,utils) now includes amod.rs. - Unified import/export logic in
lib.rsfor cleaner module access.
- Each main directory (
- Improved code readability, organization, and adherence to Rust idioms.
- 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()andhandle_import_json(). - Simplified error handling and improved localization consistency across import operations.
- Reduced code duplication and improved maintainability throughout the import module.
- CSV/JSON import deserialization error:
Theidfield in theBookstruct is now optional (Option<i32>),
preventing missing-field errors during import when the ID column is not present.
- Legacy manual
println!formatting for book listings.
-
Backup command (
librius backup)- Creates plain
.sqlitebackups in thebackups/directory - Optional
--compressflag for compressed backups.zipformat on Windows.tar.gzformat on macOS and Linux
- Localized help and messages via i18n (English and Italian)
- Timestamp-based file naming for safe sequential backups
- Fixed backup compression error on macOS/Linux (
paths in archives must be relative).
- Creates plain
-
Export command (
librius export)- Added support for exporting library data in multiple formats:
--csv(default): plain text export with semicolon delimiter--json: structured JSON array output--xlsx: formatted Excel file using umya-spreadsheet
- Localized CLI help and status messages (English/Italian)
- Automatic export directory and timestamped filenames
- Uses
dirscrate for cross-platform export path handling
- Added support for exporting library data in multiple formats:
-
Import command (
librius import)- Supports importing book data from external sources
- Available formats:
--csv(default): semicolon-delimited CSV--json: JSON array of objects
- Unified parsing via
serdeand sharedBookRecordstruct - Duplicate detection through unique index on
isbn - Uses
INSERT OR IGNOREfor idempotent imports (no duplication) - Verbose mode logs skipped records (e.g., “Skipped duplicate ISBN: …”)
- Non-blocking import completion logging
- Added migration
PATCH_004_ISBN_INDEX:- Creates unique index on
books.isbnto prevent duplicates - Automatically applied during startup migrations
- Creates unique index on
- Added dependency:
csv = "1.3"for CSV import with serde - Unified SQL insert logic via
insert_book_record()helper - Improved transaction safety and i18n message consistency
- Full internationalization (i18n) for CLI help, subcommands, and arguments.
- Embedded JSON language files (
en.json,it.json) — no external dependencies required. - Dynamic language selection via
--lang <code>or thelanguagekey inlibrius.conf(YAML).
- Resolved duplicated
--helpand--versionflag conflicts in Clap. - Restored proper
--helppropagation for subcommands (list,config). - Ensured fallback to English if an unknown language code is provided.
- Pre-language bootstrap messages (e.g., “Load configuration...”) remain in English for clarity.
- Improved initialization order: configuration and DB migrations now run after language setup.
- Default language remains English unless overridden by
--langor thelanguagefield inlibrius.conf(YAML). - This version finalizes the transition to a fully localized CLI core.
- Multilanguage support (i18n):
- Added
i18nmodule withload_language()andtr()functions. - Introduced translation files under
src/i18n/locales/(en.json,it.json). - Added
src/i18n/locales/README.mdwith key naming conventions. - CLI option
--lang(or-l) allows overriding the language from configuration. - Config file can define a
language:field for persistent preference. - Added
tr_with()utility for runtime placeholder substitution (e.g.,{path},{title}).
- Added
- Fallback system: if a translation key is missing or the language file is unavailable, English (
en.json) is used automatically. - Python helper script (
scripts/extract_translations.py):- Scans Rust source files for user-facing strings.
- Updates
en.jsonwith any missing entries without overwriting existing ones.
- All user-facing messages (
print_info,print_ok,print_err,println!, etc.) are now translatable. - Main startup sequence (
main.rs) loads the selected language before configuration and database initialization.
- Added helper in
config.rsto read language preference directly fromlibrius.conf. - Enhanced verbosity filtering to respect localized messages.
- Clearer structure for future locale additions (fr, es, de, ...).
- Structured database migration system
- Introduced
MigrationResultenum replacing the previous boolean return value. run_migrations()now returns explicit results (Applied([...])orNone).- Each applied patch is now logged in the database with detailed information.
- Introduced
- Patch safety improvements
PATCH_002now checks for the existence of columns (language,pages,genre,summary) before adding them.- Prevents duplicate column errors on repeated runs.
- Enhanced migration logging
- Migrations now record results under
DB_MIGRATION_OK,DB_MIGRATION_FAIL, andMIGRATIONS_COMPLETEDevents in thelogtable. - Clear distinction between actual migrations and up-to-date states.
- Migrations now record results under
- Refactored
run_migrations()logic for clarity and maintainability. - Updated database initialization flow (
start_db()) to react dynamically to migration results. - Improved internal output messages for migrations and startup consistency.
- Ensured safe re-execution of migration patches on existing databases.
- Removed redundant success messages when no migrations were needed.
- Unified patch logging behavior across all modules.
- Database migrations: introduced
db/migrate.rswith incremental patch system and automatic execution at startup. - Configuration migrations: added
config/migrate.rsto automatically upgrade YAML configuration files. - Logging system: new
utils::write_log()function records database and migration events into thelogtable. - Verbose mode: added global
--verboseflag for diagnostic and debug output.- Normal mode: silent operation, only command results shown.
- Verbose mode: shows configuration loading, database opening, and migration messages.
db::start_db(): unified entry point that handles opening, creating, and migrating the database automatically.- Timestamp utility: new
utils::now_str()returns ISO 8601 formatted timestamps (%+).
- Initialization messages are now hidden in normal mode.
main.rssimplified: initialization logic moved intodb::start_db().print_info()andprint_ok()now depend on verbose mode.
- Prevented redundant database initialization messages on repeated launches.
- Ensured migrations and configuration updates are idempotent and silent if up-to-date.
- feat(cli): add
configcommand with--print,--init,--edit, and--editoroptions - fix(windows): correctly handle editors with spaces in their path using
Path::new(&editor_to_use) - refactor(cli): move command and subcommand definitions into dedicated
cli.rsmodule - feat(utils): introduce
utils.rsmodule with standard CLI icons and colored output helpers - docs(readme): update structure and configuration examples
- style: minor formatting and consistency improvements across CLI output
- feat(models): add location fields to
Bookandbookstable schema (room, shelf, row, position)
- docs: add crate, module and item-level documentation for docs.rs
- feat(models): update
Bookstruct to matchbookstable schema (editor, language, pages, genre, summary, added_at) - feat(models): change
added_attype tochrono::DateTime<Utc>and enablechronoserdefeature incargo.toml - feat(cli): make
listhandler returnResultand handle errors inmain - feat(list): parse
added_atfrom DB (RFC3339 / SQLite formats) and displayadded_atin the list asYYYY-MM-DD - feat(crate): add
src/lib.rsto expose crate API and improve docs generation on docs.rs - docs: add docs.rs badge and local documentation instructions to
README.md - style: run
rustfmtand fix Clippy warnings (code style and minor refactors)