Module: EasyE::Options

Included in:
EasyE
Defined in:
lib/easy_e/options.rb

Instance Method Summary collapse

Instance Method Details

#option_parserObject



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
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/easy_e/options.rb', line 5

def option_parser
  unless @option_parser
    @option_parser = OptionParser.new do |o|
      o.banner = "Usage: #{$0} [options]"

      o.on("-v", "--[no-]verbose", "Run verbosely") do |val|
        options[:verbose] = val
      end

      o.on("-a", "--access-key <AWS ACCESS KEY>", "AWS access key") do |val|
        options[:access_key] = val
      end

      o.on("-s", "--secret-key <AWS SECRET KEY>", "AWS secret key") do |val|
        options[:secret_key] = val
      end

      o.on("-c", "--credentials-file <FILE>", "Load AWS credentials from the downloaded CSV file (overrides -a and -s)") do |val|
        options[:credentials_file] = val
      end

      o.on("-m", "--[no-]mock", "Mock out AWS calls for testing in Vagrant") do |val|
        options[:mock] = val
      end

      o.on("-l", "--logfile FILE", "Path to a file used for logging") do |filename|
        options.logfile = filename
        logger.debug filename
      end

      o.on("-d", "--directory PATH", "Only snap volumes mounted to PATH, a comma-separated list of directories") do |d|
        options.directory = d
      end
    end

    plugins.each { |plugin| plugin.collect_options @option_parser }
  end

  @option_parser
end