Skip to Content
🎉 Deeb v0.0.12 released! Install with Cargo: cargo add deeb 🎉
PostsHow to Build a Rust CLI with Built-In Data Persistence

Build a Rust CLI with Built-In Data Persistence

If you’ve ever built a CLI tool in Rust, you know the usual setup: parse commands with Clap, write logic for each subcommand, and then figure out how to store data—maybe with SQLite, maybe with JSON files.

The Deeb CLI Starter streamlines that process by giving you a ready-to-use CLI template with data persistence baked in from the start.

Why This Starter Exists

When starting a CLI project, wiring up data storage often feels like unnecessary busywork—especially for quick tools or prototypes.
This starter repo handles that for you by pairing:

  • Clap → for intuitive command parsing
  • Deeb → for lightweight, fast, and developer-friendly data persistence

With it, you can focus on your commands and business logic, not on boilerplate setup.


Getting Started

  1. Clone the repo:
git clone https://github.com/The-Devoyage/deeb-cli-starter.git cd deeb-cli-starter
  1. Copy the example environment file:
cp example.env .env
  1. Install dependencies and run the CLI:
cargo run
  1. You should see the starter help screen:
My awesome CLI with easy data persistence Usage: deeb-cli-starter <COMMAND> Commands: todo Manage Todos help Print this message or the help of the given subcommand(s) Options: -h, --help Print help

Features Out of the Box

  1. Modular Command System
    Easily extend or modify commands in the cli module. Clap handles parsing so you can focus on functionality.
#[derive(Subcommand)] pub enum RootCommands { /// Manage Todos #[command(subcommand)] Todo(TodoCommands), // Add more commands here... }
  1. Built-In Persistence
    Define a struct in the models module and store it instantly using Deeb’s insert_one or retrieve with find_many.
#[derive(Serialize, Deserialize, Collection)] pub struct Todo { name: String, task: String, } impl Todo { pub async fn new(db: &Deeb, name: String, task: String) -> CliResult<Self> { let todo = Todo::insert_one(db, Todo { name, task }, None) .await .map_err(|_e| TodoError::InsertFailed)?; Ok(todo) } ... }
⭐ Star on GitHub

Like Deeb? Star the repo to support the direction Deeb is going - or - Check out the Docs!

  1. Environment-First Configuration
    Environment variables are validated before runtime to avoid misconfiguration issues.

  2. Logging Included
    The log crate is set up and ready for use, so you can start logging debug and info messages immediately.


Example Command: Todos

This starter includes a simple todo command for managing a persistent list of tasks.

# Add a todo cargo run -- todo add "Write blog post" # List todos cargo run -- todo list

The data is automatically persisted by Deeb—no database setup required.


Perfect For

  • Rapid CLI prototyping
  • Internal tooling
  • Learning Rust with real-world persistence
  • Any small-to-medium CLI project that needs storage

Repo Link: Deeb CLI Starter


✉ One email a week. Infinite side project fuel.

Last updated on