Class: VocaBuil::OptionParserWrapper

Inherits:
Object
  • Object
show all
Defined in:
lib/voca_buil/multi_check.rb,
lib/voca_buil/_stacks/_stacks_v2_260114/multi_check.rb

Direct Known Subclasses

AbbrevCheck::OptionParserWrapper

Constant Summary collapse

OPTIONS_DEFAULT =
{ file: 'dir_tree.yaml', w_num: 5, a_num: 5, iter: nil, install: false }

Class Method Summary collapse

Class Method Details

.parse(args = ARGV) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/voca_buil/multi_check.rb', line 12

def self.parse(args = ARGV)
  options = OPTIONS_DEFAULT.dup

  options[:cmd_line] = args.join(' ') # 追加: 残ったargsを記録
  opt = ::OptionParser.new
  opt.banner = "Usage: hc check [options]"
  opt.on('-f FILE', '--file FILE', 'YAML file to use') do |v|
    options[:file] = v
  end
  opt.on('-a NUM', '--answer NUM', Integer, 'Number of answer choices(def 5)') do |v|
    options[:a_num] = v
  end
  opt.on('-q NUM', '--quiz NUM', Integer, 'Number of quiz(def 5)') do |v|
    options[:w_num] = v
  end
  opt.on('-i [NUM]', '--iterative [NUM]', Integer, 'Test iteratively (num=2)') do |v|
    options[:iter] = v.nil? ? 2 : v
  end
  opt.on('--install', 'Install sample check data') do
    options[:install] = true
  end
  # 追加: reverseモード
  opt.on('-r', '--reverse', 'Reverse quiz and answers') do
    options[:reverse] = true
  end
  opt.parse!(args)
  p options
  options
end