Class: Commands::ListActionCommand

Inherits:
AbstractListCommand show all
Defined in:
lib/commands.rb

Instance Attribute Summary

Attributes inherited from AbstractListCommand

#active, #all, #created_after, #created_before, #max_results, #no_steps, #state

Attributes inherited from Command

#arg, #commands, #description, #logger, #name

Instance Method Summary collapse

Methods inherited from Command

#get_field, #has_value, #have, #initialize, #option, #require, #require_single_jobflow, #resolve, #validate

Constructor Details

This class inherits a constructor from Commands::Command

Instance Method Details

#enact(client) ⇒ Object



1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
# File 'lib/commands.rb', line 1019

def enact(client)
  result = super(client)
  job_flows = result['JobFlows']
  count = 0
  for job_flow in job_flows do 
    if get_field(:max_results) && (count += 1) > get_field(:max_results) then
      break
    end
    logger.puts format(job_flow, ['JobFlowId', 20], ['ExecutionStatusDetail.State', 15], 
                ['Instances.MasterPublicDnsName', 50]) + job_flow['Name']
    if ! get_field(:no_steps) then
      for step in job_flow['Steps'] do
        logger.puts "   " + format(step, ['ExecutionStatusDetail.State', 15], ['StepConfig.Name', 30])
      end
    end
  end
end

#format(map, *fields) ⇒ Object



1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
# File 'lib/commands.rb', line 1005

def format(map, *fields)
  result = []
  for field in fields do
    key = field[0].split(".")
    value = map
    while key.size > 0 do
      value = value[key.first]
      key.shift
    end
    result << sprintf("%-#{field[1]}s", value)
  end
  result.join("")
end