Class: Audrey2::Options

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

Class Method Summary collapse

Class Method Details

.parse(args) ⇒ Object



51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# File 'lib/audrey2.rb', line 51

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