Class: VPM::CommandOptions::AbstractCommandOptions

Inherits:
Object
  • Object
show all
Defined in:
lib/vpm/command_options/abstract_command_options.rb

Direct Known Subclasses

Install, List

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#opts_parserObject (readonly)

Returns the value of attribute opts_parser.



4
5
6
# File 'lib/vpm/command_options/abstract_command_options.rb', line 4

def opts_parser
  @opts_parser
end

Instance Method Details

#parse!(args) ⇒ Object



6
7
8
9
10
11
# File 'lib/vpm/command_options/abstract_command_options.rb', line 6

def parse!(args)
  options = {}
  parser(options).parse!(args)

  options
end

#parser(options) ⇒ Object



13
14
15
16
17
18
19
20
21
22
# File 'lib/vpm/command_options/abstract_command_options.rb', line 13

def parser(options)
  @opts_parser ||= OptionParser.new do |parser|
    define_parser(parser, options)

    parser.on_tail("-h", "--help", "Show help") do |v|
      puts parser
      exit
    end
  end
end