Class: HammerCLIForeman::ListCommand

Inherits:
HammerCLI::Apipie::ReadCommand
  • Object
show all
Defined in:
lib/hammer_cli_foreman/commands.rb

Constant Summary collapse

DEFAULT_PER_PAGE =
20

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.command_name(name = nil) ⇒ Object



62
63
64
# File 'lib/hammer_cli_foreman/commands.rb', line 62

def self.command_name(name=nil)
  super(name) || "list"
end

Instance Method Details

#adapterObject



47
48
49
# File 'lib/hammer_cli_foreman/commands.rb', line 47

def adapter
  :table
end

#executeObject



66
67
68
69
70
71
72
73
74
75
76
# File 'lib/hammer_cli_foreman/commands.rb', line 66

def execute
  if respond_to?(:page) && respond_to?(:per_page)
    self.page ||= 1
    self.per_page ||= HammerCLI::Settings.get(:ui, :per_page) || DEFAULT_PER_PAGE
    browse_collection
  else
    retrieve_and_print
  end

  return HammerCLI::EX_OK
end

#extend_data(record) ⇒ Object



58
59
60
# File 'lib/hammer_cli_foreman/commands.rb', line 58

def extend_data(record)
  record
end

#retrieve_dataObject



51
52
53
54
55
56
# File 'lib/hammer_cli_foreman/commands.rb', line 51

def retrieve_data
  data = super
  set = HammerCLIForeman.collection_to_common_format(data)
  set.map! { |r| extend_data(r) }
  set
end