Sha256: c28becb5ff9b8f43956751ff764ec57809ff08ef2d410be5a81e277d67e4a9bb

Contents?: true

Size: 1.25 KB

Versions: 36

Compression:

Stored size: 1.25 KB

Contents

require "cf/cli/app/base"

module CF::App
  class Instances < Base
    desc "List an app's instances"
    group :apps, :info
    input :apps, :desc => "Applications whose instances to list",
          :argument => :splat, :singular => :app,
          :from_given => by_name(:app)
    def instances
      apps = input[:apps]
      fail "No applications given." if apps.empty?

      spaced(apps) do |app|
        instances =
          with_progress("Getting instances for #{c(app.name, :name)}") do
            app.instances
          end

        line unless quiet?

        spaced(instances.sort { |a, b| a.id.to_i <=> b.id.to_i }) do |i|
          if quiet?
            line i.id
          else
            display_instance(i)
          end
        end
      end
    end

    private

    def display_instance(i)
      start_line "instance #{c("\##{i.id}", :instance)}: "
      puts "#{b(c(i.state.downcase, state_color(i.state)))}"

      indented do
        if s = i.since
          line "started: #{c(s.strftime("%F %r"), :neutral)}"
        end

        if d = i.debugger
          line "debugger: port #{b(d[:port])} at #{b(d[:ip])}"
        end

        if c = i.console
          line "console: port #{b(c[:port])} at #{b(c[:ip])}"
        end
      end
    end
  end
end

Version data entries

36 entries across 36 versions & 2 rubygems

Version Path
cf-5.4.7 lib/cf/cli/app/instances.rb
cf-5.4.7.rc1 lib/cf/cli/app/instances.rb
cf-5.4.5 lib/cf/cli/app/instances.rb
cf-5.4.4 lib/cf/cli/app/instances.rb
trucker-cli-0.0.3 lib/cf/cli/app/instances.rb
cf-5.4.3 lib/cf/cli/app/instances.rb
cf-5.4.2 lib/cf/cli/app/instances.rb
trucker-cli-0.0.2 lib/cf/cli/app/instances.rb
trucker-cli-0.0.1 lib/cf/cli/app/instances.rb
cf-5.4.1 lib/cf/cli/app/instances.rb
cf-5.4.1.rc1 lib/cf/cli/app/instances.rb
cf-5.4.0 lib/cf/cli/app/instances.rb
cf-5.3.1 lib/cf/cli/app/instances.rb
cf-5.3.0 lib/cf/cli/app/instances.rb
cf-5.2.2 lib/cf/cli/app/instances.rb
cf-5.2.1.rc15 lib/cf/cli/app/instances.rb
cf-5.2.1.rc14 lib/cf/cli/app/instances.rb
cf-5.2.1.rc13 lib/cf/cli/app/instances.rb
cf-5.2.1.rc12 lib/cf/cli/app/instances.rb
cf-5.2.1.rc11 lib/cf/cli/app/instances.rb