1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00
ruby--ruby/doc/ruby/optional_argument.rb
Burdette Lamar ff0dac1849 [ruby/optparse] Rdoc (#15)
* Resolve shared mixed_names.rb

* Add long option with negation

* Show --help for all examples

* Table of contents for tutorial

* Move argument converters to separate rdoc

* Add references to argument_converters.rdoc

* Tune up argument converters

* Change explicit links to auto-links

c91ed8d33d
2021-04-11 08:52:52 +09:00

9 lines
265 B
Ruby

require 'optparse'
parser = OptionParser.new
parser.on('-x [XXX]', '--xxx', 'Optional argument via short name') do |value|
p ['--xxx', value]
end
parser.on('-y', '--yyy [YYY]', 'Optional argument via long name') do |value|
p ['--yyy', value]
end
parser.parse!