Skip to content

Instantly share code, notes, and snippets.

@akimicyu
Last active April 30, 2017 23:49
Show Gist options
  • Save akimicyu/ced058fdffe83c919ec7c41a6579da89 to your computer and use it in GitHub Desktop.
Save akimicyu/ced058fdffe83c919ec7c41a6579da89 to your computer and use it in GitHub Desktop.
require 'optparse'
p 'ウホ' if ARGV.include?('-u')
p 'いい男' if ARGV.include?('-i')
opt = OptionParser.new
opt.on('-u') {|v| p 'ウホ' }
opt.on('-i') {|v| p 'いい男' }
p '---'
opt.parse!(ARGV)
# ruby uho.rb -u -i => "ウホ いい男 --- ウホ いい男"
# ruby uho.rb -i -u => "ウホ いい男 --- いい男 ウホ"
# ruby uho.rb -ui => "(出力無し) --- ウホ いい男"
# ruby uho.rb -ui => "(出力無し) --- いい男 ウホ"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment