Class: Hammerhead::Commands::Clients

Inherits:
Hammerhead::Command show all
Defined in:
lib/hammerhead/commands/clients.rb

Overview

Implements the clients command.

This command, using a Harvest.connection, knows how to obtain a list of clients and display them in a TTY::Table. It also outputs the number of clients returned.

If any errors are caught, they are sent to the Hammerhead.logger.

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ Clients

:nodoc:



18
19
20
# File 'lib/hammerhead/commands/clients.rb', line 18

def initialize options # :nodoc:
  self.options = options
end

Instance Method Details

#execute(input: $stdin, output: $stdout) ⇒ Object

:stopdoc:

TODO: Format Table TODO: Display different table with ‘–all’ TODO: Colorize Output



28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/hammerhead/commands/clients.rb', line 28

def execute input: $stdin, output: $stdout
  clients = Harvest.connection.clients options

  output.puts "Pass the Id to the 'status' command, or enough of the name to uniquely match."
  output.puts

  table = TTY::Table.new headers, data(clients)
  output.puts table.render(:unicode)

  output.puts
  output.puts "CLIENTS FOUND: #{clients.size}"
rescue StandardError => e
  Hammerhead.logger.error 'CLIENTS COMMAND ERROR:', e
end