You are previewing Build Awesome Command-Line Applications in Ruby 2.
O'Reilly logo
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.

Table of Contents

  1. Build Awesome Command-Line Applications in Ruby 2
  2. For the Best Reading Experience...
  3. Table of Contents
  4. What Readers Are Saying About Build Awesome Command-Line Applications in Ruby
  5. 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
  6. Chapter 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
  7. Chapter 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
  8. Chapter 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
  9. Chapter 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
  10. Chapter 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
  11. Chapter 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
  12. Chapter 7: Distribute Painlessly
    1. Distributing with RubyGems
    2. Distributing Without RubyGems
    3. Collaborating with Other Developers
    4. Moving On
  13. Chapter 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
  14. Chapter 9: Be Easy to Maintain
    1. Dividing Code into Multiple Files
    2. Designing Code for Maintainability
    3. Moving On
  15. Chapter 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
  16. Appendix 1: Common Command-Line Gems and Libraries
    1. Alternatives for Simple Command-Line Apps
    2. Alternatives for Command Suites
    3. Other Relevant Libraries
  17. Bibliography
    1. You May Be Interested In…