Build Awesome Command-Line Applications in Ruby 2

Book description

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.

Publisher resources

View/Submit Errata

Table of contents

  1.  Introduction
    1. How This Book Is Organized
    2. Who This Book Is For
    3. What You’ll Need
    4. Conventions Used in the Book
    5. Online Resources
    6. Acknowledgments
  2. 1. Have a Clear and Concise Purpose
    1. Problem 1: Backing Up Data
    2. Problem 2: Managing Tasks
    3. What Makes an Awesome Command-Line App
    4. Moving On
  3. 2. Be Easy to Use
    1. Understanding the Command Line: Options, Arguments, and Commands
    2. Building an Easy-to-Use Command-Line Interface
    3. Building an Easy-to-Use Command-Suite Interface
    4. Moving On
  4. 3. Be Helpful
    1. Documenting a Command-Line Interface
    2. Documenting a Command Suite
    3. Including a Man Page
    4. Writing Good Help Text and Documentation
    5. Moving On
  5. 4. Play Well with Others
    1. Using Exit Codes to Report Success or Failure
    2. Using the Standard Output and Error Streams Appropriately
    3. Formatting Output for Use As Input to Another Program
    4. Trapping Signals Sent from Other Apps
    5. Moving On
  6. 5. Delight Casual Users
    1. Choosing Names for Options and Commands
    2. Choosing Default Values for Flags and Arguments
    3. Deciding Default Behavior
    4. Moving On
  7. 6. Make Configuration Easy
    1. Why External Configuration?
    2. Reading External Configuration from Files
    3. Using Configuration Files with Command Suites
    4. Design Considerations When Using Configuration
    5. Moving On
  8. 7. Distribute Painlessly
    1. Distributing with RubyGems
    2. Distributing Without RubyGems
    3. Collaborating with Other Developers
    4. Moving On
  9. 8. Test, Test, Test
    1. Testing User Behavior with Acceptance Tests
    2. Testing in Isolation with Unit Tests
    3. A Word About Test-Driven Development
    4. Moving On
  10. 9. Be Easy to Maintain
    1. Dividing Code into Multiple Files
    2. Designing Code for Maintainability
    3. Moving On
  11. 10. Add Color, Formatting, and Interactivity
    1. Adding Color Using ANSI Escape Sequences
    2. Formatting Output with Tables
    3. Providing Interactive User Input with readline
    4. Moving On
  12. A1. Common Command-Line Gems and Libraries
    1. Alternatives for Simple Command-Line Apps
    2. Alternatives for Command Suites
    3. Other Relevant Libraries
  13.  Bibliography

Product information

  • Title: Build Awesome Command-Line Applications in Ruby 2
  • Author(s): David B. Copeland
  • Release date: November 2013
  • Publisher(s): Pragmatic Bookshelf
  • ISBN: 9781937785758