Created
September 17, 2014 14:48
-
-
Save felinebabies/e46622717ac89d36f275 to your computer and use it in GitHub Desktop.
コマンドラインオプション解析にoptparseを使う
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# coding: utf-8 | |
require 'optparse' | |
# コマンドラインオプション解析 | |
def cmdline | |
args = {} | |
OptionParser.new do |parser| | |
parser.on('-f', '--f', '必ずつぶやく') {|v| args[:force] = v} | |
parser.parse!(ARGV) | |
end | |
return args | |
end | |
args = cmdline | |
p args[:force] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment