Skip to content

Instantly share code, notes, and snippets.

@kaosf
Created May 16, 2014 05:12
Show Gist options
  • Save kaosf/41dc3b0b4cd86386d5b8 to your computer and use it in GitHub Desktop.
Save kaosf/41dc3b0b4cd86386d5b8 to your computer and use it in GitHub Desktop.
require 'optparse'
user = nil
host = nil
path = nil
OptionParser.new do |opt|
opt.on('-u username', '--user') { |x| user = x }
opt.on('-h hostname', '--host') { |x| host = x }
opt.on('--path path') { |x| path = x }
end.parse!
p user
p host
p path
# ref. http://docs.ruby-lang.org/ja/2.1.0/library/optparse.html
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment