Skip to content

Instantly share code, notes, and snippets.

@yanmhlv
Created April 3, 2014 13:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yanmhlv/9954118 to your computer and use it in GitHub Desktop.
Save yanmhlv/9954118 to your computer and use it in GitHub Desktop.
парсинг коммандной строки
require 'optparse'
options = {}
optparse = OptionParser.new do |opts|
options[:verbose] = false
opts.banner = "Usage: #{$0} --option=value"
opts.on('-v', '--verbose') {options[:verbose] = true}
opts.on('-h', '--help') do
puts "Help message"
end
logfile = nil
opts.on('-l', '--logfile FILE') do |file|
options[:logfile] = file
end
end
optparse.parse!
puts options
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment