Skip to content

Instantly share code, notes, and snippets.

@sepulworld
Created January 17, 2015 23:22
Show Gist options
  • Save sepulworld/00a79d406866774bd9ab to your computer and use it in GitHub Desktop.
Save sepulworld/00a79d406866774bd9ab to your computer and use it in GitHub Desktop.
Ruby Script Starter
#!/usr/bin/ruby
require 'optparse'
options = {}
parser = OptionParser.new do |opts|
opts.banner = "Usage: <script_name> [options]"
options[:firstoption] = 20
opts.on("-t <integer>", "--secondoption", "Number of HTTP request threads to generate") do |t|
options[:secondoption] = t
end
opts.on("-p <string>", "--thirdoption", "Description of third option") do |p|
options[:thirdoption] = p
end
opts.on("-d <directory value>", "--product_dir", "Description of product_dir option") do |d|
options[:product_dir] = d
end
opts.on("-c <remote url>", "--remote_url", "Put nice little description here") do |c|
options[:remote_url] = c
end
opts.on("-v", "--verbose", "Output is verbose") do |v|
options[:verbose] = v
end
opts.on('-h', '--help', 'Displays Help') do
puts opts
exit
end
end
parser.parse!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment