Speak directly to your system. With its simple commands, flags, and parameters, a well-formed command-line application is the quickest way to automate a backup, a build, or a deployment and simplify your life. With this book, you'll learn specific ways to write command-line applications that are easy to use, deploy, and maintain, using a set of clear best practices and the Ruby programming language. This book is designed to make any programmer or system administrator more productive in their job. Now updated for Ruby 2.
Writing a command-line application that's self-documenting, robust, adaptable and forever useful is easier than you might think. Ruby is particularly suited to this task, because it combines high-level abstractions with "close to the metal" system interaction wrapped up in a concise, readable syntax. Plus, Ruby has the support of a rich ecosystem of open source tools and libraries.
Ten insightful chapters each explain and demonstrate a command-line best practice. You'll see how to use these tools to elevate the lowliest automation script to a maintainable, polished application. You'll learn how to use free, open source parsers to create user-friendly command-line interfaces as well as command suites. You'll see how to use defaults to keep options simple for everyday users, while giving advanced users options for more complex tasks. There's no reason why a command-line application should lack documentation, whether it's part of a help command or a man page; you'll find out when and how to use both. Your journey from command-line novice to pro ends with a look at valuable approaches to testing your apps, and includes some fun techniques for outside-the-box, colorful interfaces that will delight your users.
With Ruby, the command line is not dead. Long live the command line.
David Copeland is a programmer and author. He wrote "The Senior Software Engineer" and "Build Awesome Command-Line Applications in Ruby", and has over 16 years of professional development experience. He's managed high-performance, high-traffic systems at LivingSocial, helped build the engineering team at Opower, and worked consulting gigs both large and small. Currently, he's a lead engineer at fashion start-up Stitch Fix, building a platform that will change the retail shopping experience.
The whole book is quite basic and if you are a seasoned Ruby developer, you might not learn too many things. However I must admit that it covers all the minimum knowledge that any person doing a command line application must have.
Good if you want to solidify your knowledge of CLI programming, great if you are a beginner or expose yourself randomly to Ruby when doing small programs.
It was an easy read because I am familiar with testing CLI apps. The book discusses essential gems. It feels like reading a long version of a README file. If you have time for that, read this. Otherwise, you're better off reading documentation of gli, ronn and a few other gems.
This book describes many non rby related issues in building a command line interface. The structure of it is:
1) Parse Library to use: ParseOptions or GLI 2) Creating Help. This includes man page creation 3) Suggestions for being piped. 4) Flag usage and styles 5) Configuring via yaml 6) Creating a Gem for distribution 7) Testing 8) Add color and interativity
I designed a command line suite with it and used Thor rather than gli. Thor is commonly used whereas gli is the authors creation so he understandably wrote about it. This is the only complaint I have about the book.
This book is an excellent, practical example of leveraging Ruby outside of web development. You'll learn how easy it is to toss together Ruby scripts to act like complex, compiled CLI tools. Remove the extension, put a Ruby shebang, and drop it in your $PATH, and you will feel empowered to create versatile CLI tools that let you pipe data to Slack, or convert data. This book teaches you best practices for writing helpful and discoverable CLI tools.
Great book if you are a beginner that is interested in building small, basic command-line applications, but if you're a bit experienced with command-line applications and looking for a book to expand your knowledge this isn't for you.
If you're a looking for a introduction to how write CLI applications, it's really a good choice. It does not cover the tests parts very well, but explains the hard parts of tests like simulating changes in file system.