Class: Hotspots::OptionsParser

Inherits:
Object
  • Object
show all
Defined in:
lib/hotspots/options_parser.rb

Overview

:nodoc: all

Instance Method Summary collapse

Constructor Details

#initialize(opts) ⇒ OptionsParser



5
6
7
# File 'lib/hotspots/options_parser.rb', line 5

def initialize(opts)
  @configuration = opts[:configuration].dup
end

Instance Method Details

#parse(*args) ⇒ Object



9
10
11
12
13
14
15
16
17
# File 'lib/hotspots/options_parser.rb', line 9

def parse(*args)
  parser = new_option_parser
  begin
    parser.parse(args)
  rescue ::OptionParser::InvalidOption, ::OptionParser::InvalidArgument => ex
    @configuration.exit_strategy = Exit::Error.new(:code => 1, :message => (ex.to_s + "\nUse -h for help\n"))
  end
  @configuration
end