Choosing Names for Options and Commands
In Chapter 2, Be Easy to Use, we learned that OptionParser allows
us to create multiple options that mean the same thing. We used this feature
in our database backup script, db_backup.rb, by allowing
both -i
and --iteration
to signify an “end-of-iteration” backup. Why does OptionParser
have this feature, and why did we use it?
Naming Options
This question is better posed in two parts: “Why did we provide a short-form option?” and “Why did we provide a long-form option?” Short-form options allow frequent users who use the app on the command line to quickly specify things without a lot of typing. Long-form options allow maintainers of systems that use our app to easily understand what the options ...
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.