Sha256: c65bd3ecd62fb67160cfcb26a7eae8602b559636f01ffcb74403cc7ff0412c75

Contents?: true

Size: 1.27 KB

Versions: 29

Compression:

Stored size: 1.27 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, :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

29 entries across 29 versions & 3 rubygems

Version Path
vmc-0.5.1 lib/vmc/cli/app/instances.rb
static-1.0.3 vendor/vmc-0.5.0/lib/vmc/cli/app/instances.rb
af-0.5.0.beta.11 lib/vmc/cli/app/instances.rb
af-0.5.0.beta.10 lib/vmc/cli/app/instances.rb
vmc-0.5.1.rc6 lib/vmc/cli/app/instances.rb
static-1.0.1 vendor/vmc-0.5.0/lib/vmc/cli/app/instances.rb
vmc-0.5.1.rc5 lib/vmc/cli/app/instances.rb
vmc-0.5.1.rc4 lib/vmc/cli/app/instances.rb
af-0.5.0.beta.9 lib/vmc/cli/app/instances.rb
af-0.5.0.beta.8 lib/vmc/cli/app/instances.rb
af-0.5.0.beta.7 lib/vmc/cli/app/instances.rb
af-0.5.0.beta.6 lib/vmc/cli/app/instances.rb
vmc-0.5.1.rc3 lib/vmc/cli/app/instances.rb
af-0.5.0.beta.5 lib/vmc/cli/app/instances.rb
af-0.5.0.beta.4 lib/vmc/cli/app/instances.rb
af-0.5.0.beta.3 lib/vmc/cli/app/instances.rb
vmc-0.5.1.rc2 lib/vmc/cli/app/instances.rb
af-0.5.0.beta.2 lib/vmc/cli/app/instances.rb
af-0.5.0.beta.1 lib/vmc/cli/app/instances.rb
vmc-0.5.1.rc1 lib/vmc/cli/app/instances.rb