Ebook · 2026 Edition · PDF

Rust CLI
Mastery

Build Fast, Reliable Command-Line Tools

You know enough Rust to be dangerous. This book shows you how to build the kind of tools people install, trust, and keep using, from your first --help screen to a release on three operating systems.

  • 26 chapters
  • 4 capstone projects
  • 700+ pages
  • 3 appendices
Front cover of Rust CLI Mastery: Build Fast, Reliable Command-Line Tools by Rajeev Edmonds

the book

Stop Writing Scripts. Start Shipping Tools.

The gap between a CLI that compiles and a CLI people rely on is wider than most tutorials admit. This book closes it.

There are plenty of resources for learning Rust. Far fewer answer what comes next. How do you structure a tool so it is still pleasant to maintain a year from now? When does anyhow earn its place, and when do you want thiserror? Do you really need async here? How do you test a program whose whole job is to read files, spawn processes and print to a terminal?

Rust CLI Mastery answers those questions. It is not a language primer. It is a guide to production-grade command-line engineering that teaches decisions as much as APIs: which crate to pick, which pattern to apply, and which trade-off you are quietly accepting. Wherever there is a real choice, you get the reasoning and what the author would pick.

Every chapter opens with a real problem, walks through the thinking behind the solution, and ends with a program you can build, run and modify. By the time you reach the capstones, you are not following along anymore. You are designing.

the promise

Single static binaries. Startup times measured in milliseconds. Refactors you can trust. And a codebase built the way a thoughtful Rust developer, and a careful reviewer, would want it.

the approach

Idiomatic Rust first, runnable code at the end of every chapter, and every project pins its dependencies so the examples still compile when you sit down to type them.

what you'll learn

From First Flag to Final Release

Seven parts that take you from foundations to the habits of professional tool builders.

[design]

Interfaces that feel natural

Sensible flags, helpful errors and clean --help output with clap, plus the contract every good CLI keeps: meaningful exit codes, output for humans and for machines, and friendly behavior in pipelines.

[core]

Files, text, processes, the web

Work confidently with the file system, parse and transform text, run external commands safely, and talk to HTTP APIs, with error handling that stays readable as the tool grows.

[async + tui]

Concurrency and full-screen UIs

Build asynchronous tools with tokio and terminal interfaces with ratatui, and learn when async is worth its complexity and when it is not.

[production]

Config, logging, observability

Handle configuration and persistence the way real tools do, and replace scattered println! calls with structured logging and spans using tracing.

[testing]

Tests you can believe in

Design for testability, then layer unit, in-process, black-box, snapshot and property-based tests so a green build actually means something.

[shipping]

Cross-platform and release-ready

Produce binaries for Linux, macOS and Windows, add shell completions and man pages, publish to crates.io, automate releases, and think about supply-chain trust.

capstones

Four Complete Tools You Could Install Tomorrow

Part 6 stops teaching techniques and starts combining them. Each capstone is a full, working program with its own architecture and tests.

[capstone 1]

fsearch

A fast, parallel text search tool in the spirit of ripgrep. Skip what nobody wants to search, use every core, and print results people can read.

rayon · walkdir · regex

[capstone 2]

tudo

A full-screen task manager that lives in your terminal, keyboard-driven, backed by a single SQLite file. Learn the architecture that keeps TUIs sane.

ratatui · crossterm · rusqlite

[capstone 3]

sysmon

A live system dashboard with CPU history, memory, network, disks and a sortable process table, plus a headless JSON mode for scripts.

collector → state → renderer

[capstone 4]

devkit

A developer toolkit of small everyday commands with a plugin protocol, the same extensibility idea behind Git and Cargo.

subcommands · plugins

who it's for

Written for the Developer in the Middle

This book is for you if

  • You have a few weeks of Rust behind you. You understand ownership well enough to get code compiling and want to build things other people will run.
  • You write CLI tools every week in Python, Bash or Go. You are curious what a compiled, type-safe language gives you in return.
  • You have built a CLI or two already. The later parts on architecture, observability and distribution will still sharpen how you work.

If you have never written a line of Rust, start with a beginner resource first and come back.

Every chapter has the same shape

  • A narrative introduction that frames the problem before any code appears.
  • Annotated Rust code in numbered sections, explained line by line where it matters.
  • A mini project with full source you can run.
  • Common Mistakes and Best Practices drawn from real errors.
  • Challenge exercises, a recap and further reading.

contents

Table of Contents

26 chapters in seven parts, plus bonus material. Page numbers refer to the PDF edition.

Part 1Foundations

p. 1
  1. 1Introduction to Command-Line Tools in Rust2
  2. 2Setting Up Your Development Environment16
  3. 3Command-Line Fundamentals30
  4. 4Parsing Arguments with clap50

Part 2Core Skills

p. 82
  1. 5Working with the File System83
  2. 6Processing Text Data107
  3. 7Error Handling131
  4. 8Structuring Your Application158

Part 3Networking & Async

p. 186
  1. 9Running External Processes187
  2. 10Building HTTP Clients211
  3. 11Async Programming with tokio238
  4. 12Terminal User Interfaces with ratatui259

Part 4Testing & Distribution

p. 284
  1. 13Configuration and Persistence285
  2. 14Logging and Observability308
  3. 15Testing Command-Line Tools333
  4. 16Building Cross-Platform Tools360

Part 5Advanced

p. 380
  1. 17Designing for Production381
  2. 18Advanced Rust Patterns for CLI Tools402
  3. 19Building Developer Tools427
  4. 20Distributing and Shipping Your Tool449

Part 6Capstone Projects

p. 476
  1. 21Capstone 1: fsearch, a Fast File Search Tool477
  2. 22Capstone 2: tudo, a TUI Task Manager511
  3. 23Capstone 3: sysmon, a System Monitor544
  4. 24Capstone 4: devkit, a Developer Toolkit570

Part 7The Rust CLI Ecosystem

p. 599
  1. 25Contributing to the Rust Ecosystem600
  2. 26The Future of Rust CLI Development622

BonusMaterial

p. 641
  1. ACheat Sheets642
  2. BCrate Selection Guide680
  3. CRelease Checklist699

the author

About Rajeev Edmonds

Portrait of Rajeev Edmonds, author of Rust CLI Mastery

Rajeev Edmonds is a self-taught programmer, a professional blogger, and a firm believer that the best software tools are the small, sharp ones you can run from a terminal.

He started out as a C programmer building IVRS (Interactive Voice Response System) applications, where every byte and every failure mode mattered. That work shaped how he still thinks about software: keep it lean, keep it predictable, and never let a program fail silently. Those habits followed him into the web world, and eventually into Rust.

Today he focuses on backend development in Rust, with a particular love for command-line tools and developer utilities. His open-source work includes whence, a file-history tool for files that live outside version control, and XOSLog, a thread-safe logging library for Linux.

He is also the founder and Editor-in-Chief of Fresh Tech Tips (opens in a new tab). Years of explaining technical ideas to a broad audience taught him that a concept isn't understood until it can be explained plainly, and that principle runs through every chapter of this book. Rust CLI Mastery is written for the developer he once was. Rajeev lives in New Delhi, India.

Build something you will actually use.

That is the only reliable way to learn this craft. Get Rust CLI Mastery and start on your first tool today.

Buy the Ebook (opens in a new tab)

Secure checkout via Payhip · PDF