I received my copy of "Build Awesome Command-Line Applications in Ruby" yesterday, and devoured it overnight. When I ordered it pre-release, I was expecting something a bit different from what the title suggested: I thought it'd be another book full of Ruby com-line app recipes, a cookbook from which I could crib and adapt some new apps and ideas. It actually is an application design guide, but boy what a guide.
Author David Copeland hits just the right notes with this one; succinct and to-the-point, Copeland provides a practical guide loaded with wisdom about the command line and com-line applications -- you could use his guidelines in any programming language -- with just the right amount of Ruby language specifics. This is absolutely not a Ruby primer (plenty of other good books for that); instead, it leverages Ruby's good-fit features to illuminate the best practices in writing not just passable com-line apps, but truly great ones.
The author's expertise is apparent throughout, but he's not preachy or didactic: it's all very pragmatic (no publisher pun intended), and gets down to business with little delay or diversion. His defense of the command-line, for those who still need it, is eloquent and convincing. Code samples are directly clear and prove each point. He makes good use of available libraries and gems (OptionParser and GLI), with a good appendix on other packages and approaches to com-line parsing.
As I said, this is not a "cookbook" full of "recipes"; instead, Copeland focuses on two sample applications throughout the book, evolving each to elucidate eight overall design principles (which form the core chapters of the book). The simpler app, a database backer-upper, demonstrates the "simple and focused" app, like cp or sort; the second, a light-weight to-do list manager, exemplifies a "command-suite interface" type of app, like git or gem. Along the way, the generic command-line interface syntax is taken dissected and defined. Various com-line syntax tradeoffs and design choices are clearly explained, with special focus on things like short- and long-form options (-v vs. --verbose, for instance), default values, configuration files (using YAML), and other essential considerations.
I've been learning and using Ruby for about eighteen months now, and I'd discovered early-on the ease and power of the language's OptionParser standard library module. Unfortunately, OptionParser is rather scantly documented (e.g., in the "Pickaxe Book"), and although I've used it in several of my own apps, it turns out that I've been using it naively (wrong?) all this time! Copeland's examples have set me straight and taught me much -- my code is already better and leaner for it!
My only disappointment in the book -- and it's not a deal-breaker -- is that it does not treat the issue of command-line globbing (splat-* wildcards), and how to handle this in your app, at all. I understand how a com-line splat argument is expanded into the ARGV array, but what if you want to handle globbing yourself inside the app, before expansion? Unfortunately, this book is silent on that particular issue. Maybe a follow-on book, one with even more recipes, is already warranted? I'd love to help.
But it's so strong everywhere else... I've caught only four typos, and the errata list on the book's website ([...]) is gratifyingly brief. I like this author's style, his experience and his intentions -- I think he's written a great and useful book. Strongly recommended.