librius 0.2.1

A personal library manager CLI written in Rust.
Documentation
# ๐Ÿ“š Librius

[![Build Status](https://github.com/umpire274/librius/actions/workflows/ci.yml/badge.svg)](https://github.com/umpire274/librius/actions)
[![Docs.rs](https://docs.rs/librius/badge.svg)](https://docs.rs/librius)
[![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
[![Rust Edition](https://img.shields.io/badge/Rust-2024-orange.svg)](https://www.rust-lang.org/)

> **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.

---

## ๐Ÿ“ฆ Installation

### ๐Ÿง AUR (Arch Linux)

[![AUR](https://img.shields.io/aur/version/librius)](https://aur.archlinux.org/packages/librius)

```bash
yay -S librius
# or
paru -S librius
```

### ๐Ÿบ Homebrew (macOS/Linux)

[![Homebrew Version](https://img.shields.io/github/v/release/umpire274/librius?label=Homebrew&logo=homebrew&color=brightgreen)](https://github.com/umpire274/homebrew-tap)

```bash
brew tap umpire274/tap
brew install librius
```

### ๐Ÿฆ€ Crates.io (Rust)

[![Crates.io](https://img.shields.io/crates/v/librius)](https://crates.io/crates/librius)

```bash
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` |
|   โœ…	   | Database migrations   | 	Automatic schema upgrades at startup                                       |
|   โœ…	   | Logging system	       | Records operations and migrations in log table                              |
|   โœ…	   | Verbose mode	         | Optional --verbose flag for detailed debug output                           |
|   ๐Ÿšง   | **Add / Remove**      | Add or delete books via CLI commands                                        |
|   ๐Ÿšง   | **Search**            | Search by title, author, or ISBN                                            |
|   ๐Ÿšง   | **Export / Import**   | Export and import data (JSON, CSV)                                          |

---

## ๐Ÿ—๏ธ Architecture

```sh
ibrius/
โ”œโ”€โ”€ Cargo.toml
โ”œโ”€โ”€ src/
โ”‚ โ”œโ”€โ”€ main.rs # CLI entry point
โ”‚ โ”œโ”€โ”€ config.rs # Configuration management
โ”‚ โ”œโ”€โ”€ db.rs # SQLite initialization
โ”‚ โ”œโ”€โ”€ models.rs # Data models (Book, etc.)
โ”‚ โ””โ”€โ”€ commands/
โ”‚ โ””โ”€โ”€ list.rs # 'list' command logic
โ”œโ”€โ”€ config/
โ”‚ โ””โ”€โ”€ librius.toml # Default config file
โ””โ”€โ”€ README.md
```

---

## ๐Ÿš€ Quick start

### 1๏ธโƒฃ Clone the repository

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

### 2๏ธโƒฃ Build and run

```bash
cargo build
cargo run -- list
```

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

- The config file at `~/.config/librius/librius.toml`
- A SQLite database at `~/.config/librius/librius.db`

---

## ๐Ÿงฉ 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

```yaml
# librius.conf
database: "C:/Users/YourName/AppData/Roaming/librius/librius.db"
language_default: "English"
theme: "light"
```

- 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

---

## ๐Ÿ“š Documentation

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

- Online: https://docs.rs/librius

To generate and view the documentation locally run:

```bash
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
serde โ€” Serialization/deserialization
toml โ€” Config format support
colored โ€” Colored terminal output

---

## ๐Ÿ—„๏ธ Database management

Librius automatically checks and upgrades the SQLite database structure at startup.

- On first launch โ†’ creates books table.
- On subsequent launches โ†’ runs pending migrations silently.
- Migration results are recorded in the log table.

### 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:
```bash
librius --verbose list
```

Output example:
```bash
๐Ÿ“˜  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

```bash
cargo run -- list
```

### Run with logging (future)

```bash
RUST_LOG=debug cargo run -- add "Neuromancer"
```

### Format and lint

```bash
cargo fmt
cargo clippy
```

---

## ๐Ÿงฑ Future roadmap

- Add `add`, `remove`, and `search` commands
- Export/import JSON and CSV
- Add optional TUI (Text UI) with `ratatui`
- Multi-language support (English/Italian)
- Web dashboard sync

---

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

Umpire274
GitHub: [@umpire274](https://github.com/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!

---