Command-Line Rust: A Project-Based Primer for Writing Rust CLIs
Best for: Readers who want to learn Rust hands-on by shipping small, finished, testable programs rather than working through language-feature chapters.
- ISBN-13: 9781098109431
- Level: beginner
- Published: 2022
Command-Line Rust picks a genuinely clever teaching device: instead of
inventing toy exercises, it has you reimplement well-known Unix tools —
echo, cat, wc, uniq, find, grep, and others — one per chapter,
each with a real test suite you run against your own implementation. That
gives every chapter a built-in definition of “done” and a concrete,
familiar target, which makes the pacing unusually steady for a beginner
book.
The test-driven structure is the standout feature — Youens-Clark supplies
integration tests for each tool up front, so you’re writing code against a
specification rather than guessing whether your solution is “good enough.”
Along the way you pick up argument parsing with clap, error handling with
custom error types, file and stdin/stdout handling, and enough regex and
Unix-tool-behavior nuance (like how wc and uniq handle edge cases) to
make the reimplementations genuinely correct, not just plausible-looking.
Where it’s weaker: because the projects are all CLI tools, the book
naturally doesn’t cover concurrency, web development, or much beyond
clap-based argument parsing and file I/O — it’s a focused primer on one
slice of Rust, not a general-purpose introduction to the language’s type
system or ownership model in depth. Readers with zero prior exposure to
ownership and borrowing may want a chapter of The Rust Programming
Language alongside it for that grounding.
Compared to Rust in Action: both teach Rust through building real things rather than abstract syntax tours, but this one stays entirely within familiar, bite-sized CLI tools with tests supplied for you, making it the gentler and more beginner-friendly of the two.