Sha256: 31414a872d6334306b31014df0f9443c3d0146377ed004e56477d457caea9b65

Contents?: true

Size: 1.18 KB

Versions: 1

Compression:

Stored size: 1.18 KB

Contents

require "vmc/cli/app/base"

module VMC::App
  class Instances < Base
    desc "List an app's instances"
    group :apps, :info, :hidden => true
    input :apps, :argument => :splat, :singular => :app,
      :desc => "Applications whose instances to list",
      :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

        spaced(instances) do |i|
          if quiet?
            line i.id
          else
            display_instance(i)
          end
        end
      end
    end

    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

1 entries across 1 versions & 1 rubygems

Version Path
vmc-0.4.0.beta.94 vmc-ng/lib/vmc/cli/app/instances.rb