November 2013
Intermediate to advanced
224 pages
6h 9m
English
We saw in Chapter 2, Be Easy to Use and Chapter 3, Be Helpful that OptionParser is very powerful, particularly in the way in which its on method works. If we don’t need this power, however, OptionParser can feel a bit verbose. Often, all we want to do is have the existence/absence of flags and switches populate a Hash, like so:
| | opts.on("-u USER","--username","Database user") do |username| |
| | options[:username] = username |
| | end |
This can get tedious and add unnecessary complexity to our code. Because of this, several libraries have been developed to make this simpler. We’ll look at three different libraries that try to solve this problem and make it easier for you to specify your command-line ...
Read now
Unlock full access