class CF::Start::Target

Public Instance Methods

target() click to toggle source
# File lib/cf/cli/start/target.rb, line 14
def target
  unless input.has?(:url) || input.has?(:organization) || input.has?(:space)
    TargetPrettifier.prettify(client, self)
    return
  end

  if input.has?(:url)
    target = sane_target_url(input[:url])
    with_progress("Setting target to #{c(target, :name)}") do
      begin
        build_client(target).info # check that it's valid before setting
      rescue CFoundry::TargetRefused
        fail "Target refused connection."
      rescue CFoundry::InvalidTarget
        fail "Invalid target URI."
      end

      set_target(target)
    end
  end

  return unless client.logged_in?
  if input.has?(:organization) || input.has?(:space)
    CF::Populators::Target.new(input).populate_and_save!
  end

  return if quiet?

  invalidate_client

  line
  TargetPrettifier.prettify(client, self)
end