Module: Occi::Cli::Helpers::ListHelper

Defined in:
lib/occi/cli/helpers/list_helper.rb

Instance Method Summary collapse

Instance Method Details

#helper_list(options, output = nil) ⇒ Object


3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/occi/cli/helpers/list_helper.rb', line 3

def helper_list(options, output = nil)
  found = []

  if resource_types.include?(options.resource) || resource_type_identifiers.include?(options.resource)
    Occi::Cli::Log.debug "#{options.resource.inspect} is a resource type."
    found = list options.resource
  elsif mixin_types.include?(options.resource) || mixin_type_identifiers.include?(options.resource)
    Occi::Cli::Log.debug "#{options.resource.inspect} is a mixin type."
    found = mixin_list options.resource
  else
    Occi::Cli::Log.error "I have no idea what #{options.resource.inspect} is ..."
    raise "Unknown resource #{options.resource.inspect}, there is nothing to list here!"
  end

  helper_list_output(found, options, output)
end

#helper_list_output(found, options, output) ⇒ Object


20
21
22
23
24
# File 'lib/occi/cli/helpers/list_helper.rb', line 20

def helper_list_output(found, options, output)
  return found unless output

  puts output.format(found)
end