Method: MiGA::Cli::OptHelper#opt_common

Defined in:
lib/miga/cli/opt_helper.rb

#opt_common(opt) ⇒ Object

Common options at the end of most actions, passed to OptionParser opt No action is performed if #opt_common = false is passed Executes only once, unless #opt_common = true is passed between calls



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/miga/cli/opt_helper.rb', line 21

def opt_common(opt)
  return unless @opt_common

  if interactive
    opt.on(
      '--auto',
      'Accept all defaults as answers'
    ) { |v| self[:auto] = v }
  end
  opt.on(
    '--rand-seed INT', Integer,
    'Set this seed to initialize pseudo-randomness'
  ) { |v| srand(v) }
  opt.on(
    '-v', '--verbose',
    'Print additional information to STDERR'
  ) { |v| self[:verbose] = v }
  opt.on(
    '-d', '--debug INT', Integer,
    'Print debugging information to STDERR (1: debug, 2: trace)'
  ) { |v| v > 1 ? MiGA::MiGA.DEBUG_TRACE_ON : MiGA::MiGA.DEBUG_ON }
  opt.on(
    '-h', '--help',
    'Display this screen'
  ) do
    puts opt
    exit
  end
  opt.separator ''
  self.opt_common = false
end