1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

[ruby/optparse] Tutorial: explain custom argument converters (https://github.com/ruby/optparse/pull/19)

385dd4322d
This commit is contained in:
Burdette Lamar 2021-04-11 23:43:02 -05:00 committed by Hiroshi SHIBATA
parent bf175e7ec2
commit a15f0b9fe2
No known key found for this signature in database
GPG key ID: F9CF13417264FAC2
4 changed files with 83 additions and 4 deletions

View file

@ -0,0 +1,16 @@
# Require the OptionParser code.
require 'optparse'
# Create an OptionParser object.
parser = OptionParser.new
# Define one or more options.
parser.on('-x', 'Whether to X') do |value|
p ['x', value]
end
parser.on('-y', 'Whether to Y') do |value|
p ['y', value]
end
parser.on('-z', 'Whether to Z') do |value|
p ['z', value]
end
# Parse the command line.
parser.parse!