Ruby on the Command Line
summary
Builds a cat-like Ruby CLI that prints files or their sprintf binary output and accepts multiple file args. Uses OptionParser with a -b flag, shebang plus chmod so it runs without ruby prepended, and defaults to stdin when no args or dash is given. Adds graceful error handling: rescue prints message and exit 1, -d shows stack traces, Interrupt returns 130, rescue for EPIPE exits 0. Shows adding to PATH, installing a man page, and links to a gist and testing helpers.
AI-written summary · about
chapters (12)
- 0:00Introduction
- 0:30Printf
- 1:10Option Processor
- 1:50Printing the binary
- 2:10Making it executable
- 2:50Debugging
- 3:50Standard in
- 4:35Interrupts
- 4:55Closed Pipes
- 5:10Export Path
- 5:20Man Pages
- 5:35Export
related talks
42mUsing Ruby to Craft and Test Beautiful Command Line Applications
49mShort Order Ruby
29mCommand-Line Applications in Ruby: Design Patterns and Best...
39mThe Ruby Developer's Command Line Toolkit
34mCommand Line Applications in Ruby
34mThe Ruby Developer's Command Line Toolkit
37mBuilding maintainable command-line tools with MRuby
32mBuilding CLI Apps for Everyone
