librius 0.3.5

A personal library manager CLI written in Rust.
Documentation

Build Status Docs.rs License: MIT Rust Edition

Librius โ€” A fast, minimalist CLI to manage your personal book collection, built in Rust.


๐Ÿงพ Overview

Librius is a cross-platform command-line tool written in Rust that helps you manage your personal library.
It uses a SQLite database to store your books and a simple YAML configuration file (librius.conf) for flexible setup.

This project aims to provide a clean, modular architecture with future extensions such as search, add/remove commands, and import/export support.


โœจ New in v0.3.0

๐Ÿ†• Modern tabular output

  • Replaced the old println! list format with the tabled crate.
  • Tables now feature aligned, styled columns for improved readability.
  • Added a --short flag for compact view (ID, Title, Author, Editor, Year).
  • Added --id and --details options to view a single record:
    • --id <ID> shows a specific book by its ID.
    • --details displays all fields of the selected record in a vertical table.

๐Ÿงฉ Modular architecture

  • Standardized all modules using the mod.rs structure.
  • Each subsystem (commands, models, utils, db, config, i18n) now has a clean, isolated namespace.
  • Simplified imports using pub use re-exports in lib.rs.

๐Ÿงฑ Utility improvements

  • Added a reusable build_table() helper in utils/table.rs for consistent table rendering.
  • Introduced a dynamic build_vertical_table() helper for full record details using serde_json + tabled.
  • Implemented BookFull and BookShort structs implementing Tabled for both full and compact listings.

๐Ÿ“ฆ Installation

๐Ÿง AUR (Arch Linux)

AUR

yay -S librius
# or
paru -S librius

๐Ÿบ Homebrew (macOS/Linux)

Homebrew Version

brew tap umpire274/tap
brew install librius

๐Ÿฆ€ Crates.io (Rust)

Crates.io

cargo install rtimelogger

โš™๏ธ Features

Status Feature Description
โœ… List Display all books stored in the local database
โœ… Config management Manage YAML config via config --print, --init, --edit, and --editor
โœ… Backup Create plain or compressed database backups (.sqlite, .zip, .tar.gz)
โœ… Export Export data in CSV, JSON, or XLSX format
โœ… Import Import data from CSV or JSON files (duplicate-safe via ISBN)
โœ… Database migrations Automatic schema upgrades at startup
โœ… Logging system Records operations and migrations in log table
โœ… Multilanguage (i18n) Localized CLI (commands, help); embedded JSON; --lang + YAML language
๐Ÿšง Add / Remove Add or delete books via CLI commands
๐Ÿšง Search Search by title, author, or ISBN

๐Ÿ’ป Usage

librius list          # Full detailed list
librius list --short  # Compact list (ID, Title, Author, Editor, Year)

๐Ÿงฑ Example output

$ librius list --short

๐Ÿ“š  Personal Library
โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•

โ”Œโ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ ID โ”‚ Title                        โ”‚ Author             โ”‚ Editor       โ”‚ Year โ”‚
โ”œโ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚ 1  โ”‚ The Rust Programming Languageโ”‚ Steve Klabnik      โ”‚ No Starch    โ”‚ 2018 โ”‚
โ”‚ 2  โ”‚ Clean Code                   โ”‚ Robert C. Martin   โ”‚ Pearson      โ”‚ 2008 โ”‚
โ””โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”˜

๐ŸŒ Multilanguage support (i18n)

Librius now supports a multilingual interface.

Source Description
๐Ÿ‡ฌ๐Ÿ‡ง en.json Default English messages
๐Ÿ‡ฎ๐Ÿ‡น it.json Italian translation
๐Ÿ“„ README.md Located in src/i18n/locales/, describes key naming conventions

How it works

  • On startup, Librius loads the language defined in:
    1. CLI argument --lang / -l
    2. Configuration file language:
    3. Fallback to English (en)
  • All user-visible messages (print_info, print_err, etc.) are translated dynamically.
  • Missing keys automatically fall back to their key name or English equivalent.

Example Usage

# Default (English)
librius list

# Force Italian interface
librius --lang it list

Example config (librius.conf)

# librius.conf
database: "C:/Users/YourName/AppData/Roaming/librius/librius.sqlite"
language: "it"  # Set default language to Italian

๐Ÿงฉ Translations

All translations are stored in:

src/i18n/locales/
โ”œโ”€โ”€ en.json
โ”œโ”€โ”€ it.json
โ””โ”€โ”€ README.md

Each .json file contains keyโ€“value pairs like:

{
  "app.config.loading": "Loading configuration...",
  "db.init.ok": "Database created successfully.",
  "book.add.ok": "Book '{title}' added successfully!"
}

Variables can be inserted at runtime:

tr_with("db.path.open_existing", & [("path", & db_path)]);

๐Ÿงฑ Project structure

src/
โ”œโ”€ main.rs
โ”œโ”€ lib.rs
โ”œโ”€ cli.rs
โ”‚
โ”œโ”€ commands/
โ”‚   โ”œโ”€ mod.rs
โ”‚   โ”œโ”€ list.rs
โ”‚   โ”œโ”€ backup.rs
โ”‚   โ”œโ”€ config.rs
โ”‚   โ”œโ”€ export.rs
โ”‚   โ””โ”€ import.rs
โ”‚
โ”œโ”€ config/
โ”‚   โ”œโ”€ mod.rs
โ”‚   โ”œโ”€ load_config.rs
โ”‚   โ””โ”€ migrate_config.rs
โ”‚
โ”œโ”€ db/
โ”‚   โ”œโ”€ mod.rs
โ”‚   โ”œโ”€ load_db.rs
โ”‚   โ””โ”€ migrate_db.rs
โ”‚
โ”œโ”€ i18n/
โ”‚   โ”œโ”€ mod.rs
โ”‚   โ”œโ”€ loader.rs
โ”‚   โ””โ”€ locales/
โ”‚       โ”œโ”€ en.json
โ”‚       โ”œโ”€ it.json
โ”‚       โ””โ”€ README.md
โ”‚
โ”œโ”€ models/
โ”‚   โ”œโ”€ mod.rs
โ”‚   โ””โ”€ book.rs
โ”‚
โ””โ”€ utils/
    โ”œโ”€ mod.rs
    โ””โ”€ table.rs

๐Ÿงพ Changelog reference

See CHANGELOG.md for a detailed list of changes and updates.


๐Ÿ“ค Export & ๐Ÿ“ฅ Import

Librius now supports full data import/export functionality.

Export

You can export your library to multiple formats:

librius export --csv     # CSV (default)
librius export --json    # JSON
librius export --xlsx    # Excel (XLSX)

Exports are automatically saved in your user data directory (e.g. ~/.config/librius/exports or %APPDATA%\librius\exports).

Import

Import books from CSV or JSON files:

librius import --file examples/books.csv
librius import --file examples/books.json --json

Features:

  • Automatic detection of duplicate records via unique isbn
  • Skips duplicates gracefully (no interruption)
  • Transaction-safe import
  • Verbose mode logs skipped ISBNs

Example output:

๐Ÿ“˜  Skipped duplicate ISBN: 978-0-345-33968-3
โœ… Imported 6 records from CSV file.

๐Ÿš€ Quick start

1๏ธโƒฃ Clone the repository

git clone https://github.com/umpire274/librius.git
cd librius

2๏ธโƒฃ Build and run

cargo build
cargo run -- list

If this is the first launch, Librius will automatically create:

  • The config file at ~/.config/librius/librius.conf
  • A SQLite database at ~/.config/librius/librius.sqlite

๐Ÿงฉ Example output

$ librius list

๐Ÿ“š Your Library

  1. The Hobbit (J.R.R. Tolkien) [1937]
  2. Foundation (Isaac Asimov) [1951]
  3. Dune (Frank Herbert) [1965]

โš™๏ธ Configuration

# librius.conf
database: "C:/Users/YourName/AppData/Roaming/librius/librius.sqlite"
language: "en"
  • Configuration file is automatically migrated if fields are missing or renamed.
  • Default path:
    • macOS/Linux โ†’ $HOME/.librius/librius.conf
    • Windows โ†’ %APPDATA%\Roaming\librius\librius.conf

๐Ÿงฉ Development notes

Librius now follows a standard Rust modular structure:

  • Each domain (commands, db, config, models, utils, i18n) exposes its API via mod.rs.
  • Common utilities like build_table() are reused across commands for consistent output.
  • The lib.rs re-exports all major modules for cleaner imports in main.rs.

Example import

use librius::{build_cli, handle_list; tr};

๐Ÿ“š Documentation

The API and user-facing documentation for Librius is available on docs.rs:

To generate and view the documentation locally run:

cargo doc --no-deps --open

This will build the documentation and open it in your default browser.


๐Ÿงฐ Dependencies

  • clap โ€” Command-line argument parsing
  • rusqlite โ€” SQLite database integration
  • serde / serde_json โ€” Serialization/deserialization
  • serde_yaml โ€” YAML config parsing
  • umya-spreadsheet โ€” XLSX file creation
  • csv โ€” CSV import/export
  • colored โ€” Colored terminal output
  • chrono โ€” Date and time utilities

๐Ÿ—„๏ธ Database management

Librius automatically verifies and upgrades the SQLite database schema at startup.

The latest migration adds a unique index on isbn to guarantee that duplicate imports are ignored safely.

CREATE UNIQUE INDEX IF NOT EXISTS idx_books_isbn ON books(isbn);
  • On first launch โ†’ creates books table.
  • On subsequent launches โ†’ runs pending migrations silently.
  • Migration results are recorded in the log table.

Each migration patch (PATCH_001, PATCH_002, โ€ฆ) is applied once and recorded in the internal log table. The process is fully idempotent โ€” no duplicate operations are ever performed.

๐Ÿ“˜  Applying database patch: PATCH_002
โœ…  All pending migrations applied.
โœ…  Database schema is up-to-date.

Example table log

id date operation target message
1 2025-10-13T21:45:12+02:00 DB_CREATED DB Created new database
2 2025-10-13T21:45:13+02:00 DB_MIGRATION_OK DB Schema updated successfully

๐Ÿ” Verbose mode

Run Librius in diagnostic mode to display all internal initialization steps:

librius --verbose list

Output example:

๐Ÿ“˜  Loading configuration...
๐Ÿ“˜  Opening existing database at: C:\Users\A.Maestri\AppData\Roaming\librius\librius.db
โœ… Database schema is up-to-date.
โœ… Configuration verified.

๐Ÿ“š Your Library

In normal mode, only command output is displayed.


๐Ÿงช Development

Run in debug mode

cargo run -- list

Run with logging (future)

RUST_LOG=debug cargo run -- add "Neuromancer"

Format and lint

cargo fmt
cargo clippy

๐Ÿงฑ Future roadmap

  • Add add, remove, and search commands
  • Export/import JSON and CSV
  • Add optional TUI (Text UI) with ratatui
  • Web dashboard sync

๐Ÿง‘โ€๐Ÿ’ป Author

Umpire274 GitHub: @umpire274


๐Ÿ“œ License

This project is licensed under the MIT License โ€” see the LICENSE


โญ Contribute

Contributions, feature requests, and ideas are welcome! If youโ€™d like to contribute, please open a pull request or start a discussion.


๐Ÿงก Support

If you enjoy this project, please โญ star the repository โ€” it helps visibility and development motivation!