| 1 | require 'optparse' |
| 2 | parser = OptionParser.new |
| 3 | def xxx_handler(value) |
| 4 | p ['Handler method for -xxx called with value:', value] |
| 5 | end |
| 6 | parser.on('--xxx', 'Option with no argument', method(:xxx_handler)) |
| 7 | def yyy_handler(value) |
| 8 | p ['Handler method for -yyy called with value:', value] |
| 9 | end |
| 10 | parser.on('--yyy YYY', 'Option with required argument', method(:yyy_handler)) |
| 11 | parser.parse! |