Build Awesome Command-Line Applications in Ruby: Control Your Computer, Simplify Your Life

Build Awesome Command-Line Applications in Ruby: Control Your Computer, Simplify Your Life

by David B. Copeland

Paperback

$29.70 $33.00 Save 10% Current price is $29.7, Original price is $33. You Save 10%.
Want it by Thursday, November 15 Order now and choose Expedited Shipping during checkout.

Product Details

ISBN-13: 9781934356913
Publisher: Pragmatic Programmers, LLC, The
Publication date: 03/19/2012
Pages: 225
Product dimensions: 7.50(w) x 8.90(h) x 0.80(d)

About the Author

David Bryant Copeland is a veteran professional software developer who spends most of his time on the command line. He speaks frequently at national and regional Ruby conferences and built many command-line and web applications, using the command-line to productive effect.

Table of Contents

Introduction vii

1 Have a Clear and Concise Purpose 1

1.1 Problem 1: Backing Up Data 2

1.2 Problem 2: Managing Tasks 5

1.3 What Makes an Awesome Command-Line App 10

1.4 Moving On 11

2 Be Easy to Use 13

2.1 Understanding the Command Line: Options, Arguments, and Commands 13

2.2 Building an Easy-to-Use Command-Line Interface 18

2.3 Building an Easy-to-Use Command-Suite Interface 23

2.4 Moving On 31

3 Be Helpful 33

3.1 Documenting a Command-Line Interface 33

3.2 Documenting a Command Suite 38

3.3 Including a Man Page 42

3.4 Writing Good Help Text and Documentation 47

3.5 Moving On 50

4 Play Well with Others 53

4.1 Using Exit Codes to Report Success or Failure 54

4.2 Using the Standard Output and Error Streams Appropriately 59

4.3 Formatting Output for Use as Input to Another Program 63

4.4 Trapping Signals Sent from Other Apps 68

4.5 Moving On 69

5 Delight Casual Users 71

5.1 Choosing Names for Options and Commands 72

5.2 Choosing Default Values for Flags and Arguments 76

5.3 Deciding Default Behavior 86

5.4 Moving On 86

6 Make Configuration Easy 89

6.1 Why External Configuration? 89

6.2 Reading External Configuration from Files 90

6.3 Using Configuration Files with Command Suites 94

6.4 Design Considerations When Using Configuration 98

6.5 Moving On 99

7 Distribute Painlessly 101

7.1 Distributing with RubyGems 101

7.2 Distributing Without RubyGems 108

7.3 Collaborating with Other Developers 109

7.4 Moving On 115

8 Test, Test, Test 117

8.1 Testing User Behavior with Acceptance Tests 118

8.2 Testing in Isolation with Unit Tests 131

8.3 A Word About Test-Driven Development 139

8.4 Moving On 139

9 Be Easy to Maintain 141

9.1 Dividing Code into Multiple Files 141

9.2 Designing Code for Maintainability 146

9.3 Moving On 151

10 Add Color, Formatting, and Interactivity 153

10.1 Adding Color Using ANSI Escape Sequences 154

10.2 Formatting Output with Tables 159

10.3 Providing Interactive User Input with readline 164

10.4 Moving On 173

Al Common Command-Line Gems and Libraries 175

A1.1 Alternatives for Simple Command-Line Apps 176

A1.2 Alternatives for Command Suites 184

A1.3 Other Relevant Libraries 189

A2 Bibliography 193

Index 195

Customer Reviews

Most Helpful Customer Reviews

See All Customer Reviews