class Crowbar::Client::Command::Role::List

Implementation for the role list command

Public Instance Methods

execute() click to toggle source
# File lib/crowbar/client/command/role/list.rb, line 36
def execute
  validate_barclamp! args.barclamp

  request.process do |request|
    case request.code
    when 200
      formatter = Formatter::Array.new(
        format: provide_format,
        headings: ["Role"],
        values: Filter::Array.new(
          filter: provide_filter,
          values: content_from(request)
        ).result
      )

      if formatter.empty?
        err "No roles"
      else
        say formatter.result
      end
    when 404
      err "Barclamp does not exist"
    else
      err request.parsed_response["error"]
    end
  end
end
request() click to toggle source
# File lib/crowbar/client/command/role/list.rb, line 30
def request
  @request ||= Request::Role::List.new(
    args
  )
end

Protected Instance Methods

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