Method: Fixman::CommandLine#parse_options!

Defined in:
lib/fixman/command_line.rb

#parse_options!(args) ⇒ Object



40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/fixman/command_line.rb', line 40

def parse_options!(args)
  options = {}
  options[:conf_path] =
    Pathname.new Fixman::Configuration::DEFAULT_CONF_FILE

  parser = OptionParser.new do |opts|
    opts.banner = "Usage: #{NAME} [option]"

    opts.on_tail('-h', '--help', 'Display this message') do
      puts 'help' # TODO
      exit 0
    end

    opts.on('-v', '--version', 'Display the version') do
      puts VERSION
      exit 0
    end

    opts.on('-c', '--configuration-file PATH') do |path|
      options[:conf_path] = Pathname.new path
    end
  end

  begin
    parser.parse! args
  rescue OptionParser::InvalidaOption
    error usage
  end

  options
end