Jump to ratings and reviews
Rate this book

Command-Line Rust: A Project-Based Primer for Writing Rust CLIs

Rate this book
For several consecutive years, Rust has been voted "most loved programming language" in Stack Overflow's annual developer survey. This open source systems programming language is now used for everything from game engines and operating systems to browser components and virtual reality simulation engines. But Rust is also an incredibly complex language with a notoriously difficult learning curve.

Rather than focusing on the language as a whole, this guide teaches Rust using a single small, complete, focused program in each chapter. Author Ken Youens-Clark shows you how to start, write, and test each of these programs to create a finished product. You'll learn how to handle errors in Rust, read and write files, and use regular expressions, Rust types, structs, and more.

400 pages, Paperback

Published February 1, 2022

58 people are currently reading
173 people want to read

About the author

Ratings & Reviews

What do you think?
Rate this book

Friends & Following

Create a free account to discover what your friends think of this book!

Community Reviews

5 stars
12 (30%)
4 stars
16 (40%)
3 stars
8 (20%)
2 stars
1 (2%)
1 star
3 (7%)
Displaying 1 - 7 of 7 reviews
1 review
August 5, 2022
The book starts somewhat nice, espacially with the inclusion of tests from the very beginning. However it has some problems:
- the used libraries and examples are outdated. For example the way clap is used is not supported anymore
- the examples don't get more complex. Sure, new functionality is getting introduced, but the complexity stays really low
- The programming examples are nonideomatic Rust. It reads like a Python developer is using the Rust syntax.
Profile Image for Federico Lucifredi.
Author 3 books6 followers
June 24, 2022
Teaches you rust and test-driven programming by cloning a bunch of standard Unix utilities. What's more, it teaches you how to write and package Unix shell commands in proper Rust convention.

Professor Bruce Molay used to teach his systems programming class in this style at Harvard — sans the Rust bit, of course.
Profile Image for Oscar Cortez.
2 reviews1 follower
January 29, 2022
Enough to get started in Rust programming language and start building or ¿hacking? your own CLI app.

Loved the examples and the simplicity to build the things.
Profile Image for Ricardo Signes.
69 reviews6 followers
January 14, 2024
This has not been my favorite Rust book. As is often the case with technical books, it's hard to say how much of this is about the book and how much is about me. Also, some of it has been about Rust.

I have silly little complaints. The chapter titles are all puns, meaning I can't glance at the table of contents and know what chapter is what without thinking. The way that tasks and information are doled out somehow just doesn't rub me the right way. There are things of little or unclear consequence that just bug me. This isn't anybody's problem but mine, but it colors everything else.

My bigger problems were:

* The book uses Clap for argument parsing, but uses a form that doesn't generate a struct, meaning that to get argument X, you're passing the string "X" to a method. This means that typos and type-based checks can't be caught at compile time, significantly reducing the value available in a language like Rust. I wish it'd used the struct version.

* There's a great resource in that there's a reference implementation for the book's programs, along with test suites for them. This is a big deal and should not be undersold. But the bad part is that the test output is bad. This is because (in my Perl-influenced opinion) almost all Rust test output is bad. Further, the test code isn't well commented. If tests had comments like "if this one failed, checked whether XYZ", it would've been a big learning aid.

* It felt unclear to me how much I could skip based on existing Rust experience. The book spent time introducing some concepts much more than I needed, but really didn't get into other topics that it did cover. (By the end, I was skimming a fair bit, so this problem may not be throughout, but it was present.)

* For whatever reason, I found the order in which each chapter was presented to be confusing. I might have expected "make it pass test 1, then 2, then 3", but it felt more like "here is how to implement various parts of this, and if you go stick them together you will see it all work." That meant I had no positive feedback of passing tests as I went, until I committed to working that way myself.

All that said, this book was okay — but I don't think I'll be pushing anybody toward it. The best thing about it was surely the source repository, though. I may yet refer to some of that as I try to redo some of this work on my own.
Profile Image for Mochammad Hadyan.
123 reviews4 followers
December 12, 2023
If you want to learn Rust by practice, it's really recommended to read this book.

As the title suggest, each chapter will guide you on how to write CLI program using Rust mimicking Linux command line like cat, grep, wc, etc.

Interestingly, the author still explain the fundamental concept via real world example. So you will not missing out the theory while still able to make your hands dirty
Profile Image for George Reilly.
128 reviews11 followers
December 23, 2022
The author works his way through (partial) reimplementions of many of the Unix command-line tools, such as echo, cat, wc, grep, find, and ls. In each chapter, he brings in new facets of Rust, covering much of the language and introducing several useful libraries. I liked that he used a test-first approach throughout, forcing you to think about corner cases. I found the humor a bit grating and there was an unnecessary degree of repetition in each chapter.

Overall, a good primer on writing CLI tools in Rust.
Displaying 1 - 7 of 7 reviews

Can't find what you're looking for?

Get help and learn more about the design.