Class: Claws::Options

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

Class Method Summary collapse

Class 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
33
34
35
# File 'lib/claws/options.rb', line 5

def self.parse
  options = OpenStruct.new(
    {
      :connect => true,
      :source => 'ec2',
      :choice => nil,
    }
  )

  OptionParser.new do |opts|
    opts.banner = "Usage: script/aws [options] [environment] [role]"

    opts.on('-d', '--display-only', 'display host information only and exit') do
      options.connect = false
    end

    opts.on('-c', '--choice N', Float, 'enter the identity number of the host to automatically connect to') do |n|
      options.choice = n.to_i
    end

    opts.on('-s', '--source', 'define the AWS source - default is ec2') do
      options.source = 'elb'
      options.connect = false
    end
  end.parse!

  options.environment = ARGV.shift
  options.role = ARGV.shift

  options
end