Class: Command

Inherits:
Object show all
Defined in:
lib/maws/command.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ Command

Returns a new instance of Command.



15
16
17
18
# File 'lib/maws/command.rb', line 15

def initialize(config)
  @config = config
  @maws = nil
end

Instance Attribute Details

#connectionObject

Returns the value of attribute connection.



4
5
6
# File 'lib/maws/command.rb', line 4

def connection
  @connection
end

#mawsObject

Returns the value of attribute maws.



4
5
6
# File 'lib/maws/command.rb', line 4

def maws
  @maws
end

Instance Method Details

#add_generic_options(parser) ⇒ Object



29
30
31
32
33
34
35
36
37
38
39
# File 'lib/maws/command.rb', line 29

def add_generic_options(parser)
  available_roles = @config.available_roles.join(', ')
  parser.opt :selection, "Selection of instances
       any of the following:
           zones (a, b, c, etc.)
           indexes (2, 1-10, 5-, -10, *) where * is all existing indexes and blank means all defined in profile
           role names (available: #{available_roles})
       in any order and separated by spaces", :type => :string, :default => nil
  parser.opt :prefix, "Prefix", :short => '-p', :type => :string, :default => ""
  parser.opt :region, "Region", :short => '-R', :type => :string, :default => @config.config.default_region
end

#add_specific_options(parser) ⇒ Object



41
42
# File 'lib/maws/command.rb', line 41

def add_specific_options(parser)
end

#descriptionObject



6
7
8
# File 'lib/maws/command.rb', line 6

def description
  "command - does nothing"
end

#instancesObject



10
11
12
# File 'lib/maws/command.rb', line 10

def instances
  maws.instances
end

#process_optionsObject



44
45
46
47
# File 'lib/maws/command.rb', line 44

def process_options
  @config.region = @config.command_line.region
  @config.prefix = @config.command_line.prefix
end

#run!Object



24
25
26
# File 'lib/maws/command.rb', line 24

def run!
  puts "generic command does nothing"
end

#verify_configsObject



59
60
# File 'lib/maws/command.rb', line 59

def verify_configs
end

#verify_optionsObject



49
50
51
52
53
54
55
56
57
# File 'lib/maws/command.rb', line 49

def verify_options
  if @config.command_line.region.blank?
    Trollop::die "Region must be specified in command line options OR as 'default_region' in #{@config.config.paths.config}"
  end

  if @config.command_line.selection.nil?
    Trollop::die "Must specify a selection of some instances"
  end
end