Class: Audrey2::Options

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

Class Method Summary collapse

Class Method Details

.parse(args) ⇒ Object



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/audrey2.rb', line 29

def self.parse(args)
  options = {}

  opts = OptionParser.new do |opts|
    opts.banner = "Usage: feedme [OPTIONS] recipes"

    options[:config] = '/etc/audrey2.conf'
    opts.on( '--config CONFIGFILE', "Location of config file", "(default: /etc/audrey2.conf)" )  do |f|
      options[:config] = f
    end

    opts.on_tail( '-h', '--help', 'Display this screen' ) do
      puts opts
      exit
    end

    begin
      opts.parse! args
      options
    rescue OptionParser::ParseError => e
      warn e.message
      $stderr.puts opts
      exit 1
    end
  end

  options
end