Module: Options

Included in:
Runner
Defined in:
lib/options.rb

Instance Method Summary collapse

Instance Method Details

#optsObject



5
6
7
# File 'lib/options.rb', line 5

def opts
  @opts ||= OptionParser.new
end

#parse_attach_volume_options(args, defaults = {}) ⇒ Object



28
29
30
31
32
33
34
# File 'lib/options.rb', line 28

def parse_attach_volume_options(args, defaults={})
  opts.on("-v", "--volume-id VOLUME_ID") { |volume_id| defaults[:volume_id] = volume_id }
  opts.on("-d", "--device [DEVICE]") { |device| defaults[:device] = device }
  opts.banner = "Usage: goec2 attach_volume INSTANCE_NAME [options]"
  opts.parse!(args)
  defaults
end

#parse_spinup_options(args, defaults = {}) ⇒ Object



9
10
11
12
13
14
15
16
17
18
# File 'lib/options.rb', line 9

def parse_spinup_options(args, defaults={})
  opts.on('-n', '--name NAME', "The name to use for the instance (note: this is local to this machine. It does not affect Amazon EC2 AT ALL") { |name| defaults[:name] = name }
  opts.on('-s', '--size SIZE', "The size of the instance per EC2 documentation") { |size| defaults[:instance_size] = size }
  opts.on('-f', '--user-data-file PATH', "Path to a user data file to pass into the instance") { |path| defaults[:user_data_file] = path }
  opts.on('-a', '--ami-id AMI_ID', "The AMI ID of the image with which to boot this machine") { |ami_id| defaults[:ami_id] = ami_id }
  opts.on('-z', '--zone ZONE', "The zone in which to boot this machine per EC2 documentation") { |zone| defaults[:zone] = zone }
  opts.banner = "Usage: goec2 spinup [options]"
  opts.parse!(args)
  defaults
end

#parse_ssh_options(args, defaults = {}) ⇒ Object



20
21
22
23
24
25
26
# File 'lib/options.rb', line 20

def parse_ssh_options(args, defaults={})
  opts.on("-u", "--user [NAME]", "The user to pass to ssh") { |name| defaults[:user] = name }
  opts.on("-i", "--private-key [KEY_PATH]", "The path to the SSH private key") { |name| defaults[:keypair_path] = name }
  opts.banner = "Usage: goec2 ssh INSTANCE_NAME [options]"
  opts.parse!(args)
  defaults
end