Class: PVN::App::Base::CmdLineArgs

Inherits:
Object
  • Object
show all
Includes:
Logue::Loggable
Defined in:
lib/pvn/command/clargs.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(optset, args) ⇒ CmdLineArgs

Returns a new instance of CmdLineArgs.



29
30
31
32
33
# File 'lib/pvn/command/clargs.rb', line 29

def initialize optset, args
  @optset = optset
  process args
  @unprocessed = args
end

Instance Attribute Details

#unprocessedObject (readonly)

Returns the value of attribute unprocessed.



27
28
29
# File 'lib/pvn/command/clargs.rb', line 27

def unprocessed
  @unprocessed
end

Class Method Details

.has_option(name) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/pvn/command/clargs.rb', line 13

def has_option name
  define_method name do
    info "name: #{name}"
    self.instance_eval do
      meth = name
      info "meth: #{meth}"
      val = @optset.send name
      info "val: #{val}"
      val
    end
  end
end

Instance Method Details

#process(args) ⇒ Object



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/pvn/command/clargs.rb', line 35

def process args
  options_processed = Array.new
  
  while !args.empty?
    processed = false
    @optset.options.each do |opt|
      if opt.process args
        processed = true
        options_processed << opt
      end
    end

    break unless processed
  end

  options_processed.each do |opt|
    opt.post_process @optset, args
  end
end