Ruby 2.3.0 リファレンスマニュアル > ライブラリ一覧 > optparseライブラリ > OptionParserクラス > help

instance method OptionParser#help

help -> String[permalink][rdoc]
to_s -> String

サマリの文字列を返します。



require "optparse"

options = {}
opts = OptionParser.new do |opts|
  opts.banner = "Usage: example.rb [options]"

  opts.on("-v", "--[no-]verbose", "Run verbosely") do |v|
    options[:verbose] = v
  end
end

puts opts.help

# => Usage: example.rb [options]
#    -v, --[no-]verbose               Run verbosely