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 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access