Understanding the Command Line: Options, Arguments, and Commands

To tell a command-line application how to do its work, you typically need to enter more than just the name of its executable. For example, we must tell grep which files we want it to search. The database backup app, db_backup.rb, that we introduced in the previous chapter needs a username and password and a database name in order to do its work. The primary way to give an app the information it needs is via options and arguments, as depicted in Figure 1, Basic parts of a command-line app invocation. Note that this format isn’t imposed by the operating system but is based on the GNU standard for command-line apps.[13] Before we learn how to make a command-line interface that can ...

Get Build Awesome Command-Line Applications in Ruby 2 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.