Skip to content

Instantly share code, notes, and snippets.

@danielribeiro
Last active May 31, 2016 06:04
Show Gist options
  • Save danielribeiro/98e36f7d1ae3e19d87e5729fc98c7297 to your computer and use it in GitHub Desktop.
Save danielribeiro/98e36f7d1ae3e19d87e5729fc98c7297 to your computer and use it in GitHub Desktop.
optparsing.rb
#!/usr/bin/env ruby
require 'optparse'
require 'pp'
options = {}
parser = OptionParser.new do |opts|
opts.banner = "Usage: example.rb [options]"
opts.on("-v", "--[no-]verbose", "Run verbosely") do |v|
options[:verbose] = v
end
opts.on("-i", "--integer=int", Integer, "gives integer") do |v|
options[:integer] = v
end
end
pr = proc do |event, file, line, id, binding, classname|
puts("TraceALLThings (%8s) %s:%-2d %s#%s\n" % [event, file, line, classname, id])
end
# set_trace_func(pr)
parser.parse!
puts parser
p options
p ARGV
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment