summaryrefslogtreecommitdiff
path: root/doc/optparse/ruby/basic.rb
blob: 91d37627c02f80eb4cff3cd17ecaaae8c26341cb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# 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 and return pared-down ARGV.
p parser.parse!