The first one is quite normal, works as expected.
OptionParser.parse do |parser|
parser.on("-h", "--help", "Show config help") do
puts "config --help"
exit
end
parser.on("-v", "--version", "Print the version") do
puts "config --version"
exit
end
end
The second will exit directly, which indicates the program doesn’t execute in sequence but following a nested order.
OptionParser.parse do |parser|
parser.on("-h", "--help", "Show config help") do
puts "config --help"
end
parser.on("-v", "--version", "Print the version") do
puts "config --version"
end
exit
end