Ruby Language OptionParser Long descriptions


Sometimes your description can get rather long. For instance irb -h lists on argument that reads:

  --context-mode n  Set n[0-3] to method to create Binding Object,
                    when new workspace was created

It's not immediately clear how to support this. Most solutions require adjusting to make the indentation of the second and following lines align to the first. Fortunately, the on method supports multiple description lines by adding them as separate arguments:

  opts.on("--context-mode n",
          "Set n[0-3] to method to create Binding Object,",
          "when new workspace was created") do |n|
    optons[:context_mode] = n

You can add as many description lines as you like to fully explain the option.