Class: HFAM::ArgumentParser

Inherits:
Object
  • Object
show all
Defined in:
lib/hfam/argument_parser.rb

Instance Method Summary collapse

Instance Method Details

#parseObject



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/hfam/argument_parser.rb', line 5

def parse
  options = {}

  o = ::OptionParser.new do |opts|

    opts.banner = ::HFAM::HELP
    
    opts.on("-h", "--help") do |h|
      options[:help] = ::HFAM::HELP
    end

    opts.on("-p=PATH", "--path=PATH") do |p|
      options[:path] = p
    end

  end
begin
  o.parse!
rescue ::OptionParser::InvalidOption => e
  $stderr.puts e
  $stderr.puts o.banner
  exit
rescue ::OptionParser::MissingArgument => e
  $stderr.puts e
  exit
end
  options
end