class Crowbar::Client::Command::Barclamp::List

Implementation for the barclamp list command

Public Instance Methods

execute() click to toggle source
# File lib/crowbar/client/command/barclamp/list.rb, line 34
def execute
  request.process do |request|
    case request.code
    when 200
      formatter = Formatter::Array.new(
        format: provide_format,
        headings: ["Barclamp"],
        values: Filter::Array.new(
          filter: provide_filter,
          values: content_from(request)
        ).result
      )

      if formatter.empty?
        err "No barclamps"
      else
        say formatter.result
      end
    else
      err request.parsed_response["error"]
    end
  end
end
request() click to toggle source
# File lib/crowbar/client/command/barclamp/list.rb, line 28
def request
  @request ||= Request::Barclamp::List.new(
    args
  )
end

Protected Instance Methods

content_from(request) click to toggle source
# File lib/crowbar/client/command/barclamp/list.rb, line 60
def content_from(request)
  request.parsed_response.keys.sort
end