class Smith::Commands::Kill
Public Instance Methods
execute()
click to toggle source
# File lib/smith/commands/agency/kill.rb, line 9 def execute work = ->(acc, uuid, iter) do if agents.exist?(uuid) agents[uuid].kill else acc << uuid end iter.return(acc) end done = ->(errors) { responder.succeed(format_error_message(errors)) } EM::Iterator.new(agents_to_kill).inject([], work, done) end
Private Instance Methods
agents_to_kill()
click to toggle source
# File lib/smith/commands/agency/kill.rb, line 27 def agents_to_kill if options[:group] agents.find_by_name(agent_group(options[:group])).map(&:uuid) else target end end
format_error_message(errors)
click to toggle source
# File lib/smith/commands/agency/kill.rb, line 35 def format_error_message(errors) errors = errors.compact case errors.size when 0 '' when 1 "Agent does not exist: #{errors.first}" else "Agents do not exist: #{errors.join(", ")}" end end
options_spec()
click to toggle source
# File lib/smith/commands/agency/kill.rb, line 47 def options_spec banner "Kill an agent/agents.", "<uuid[s]>" opt :group, "kill agents in this group", :type => :string, :short => :g end