class Crowbar::Client::Command::Node::Show

Implementation for the node show command

Public Instance Methods

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

      if formatter.empty?
        err "No result"
      elsif args.name == "help"
        err "Node does not exist"
      else
        say formatter.result
      end
    when 404
      err "Node does not exist"
    else
      err request.parsed_response["error"]
    end
  end
end
request() click to toggle source
# File lib/crowbar/client/command/node/show.rb, line 28
def request
  @request ||= Request::Node::Show.new(
    args
  )
end

Protected Instance Methods

content_from(request) click to toggle source
# File lib/crowbar/client/command/node/show.rb, line 65
def content_from(request)
  request.parsed_response
end