Sha256: c6e171aa7ecfb9141eeeded1ecbdcc2a422638215b49cc6a66961b1f5e83d6eb

Contents?: true

Size: 1.08 KB

Versions: 5

Compression:

Stored size: 1.08 KB

Contents

require "vmc/detect"

require "vmc/cli/service/base"

module VMC::Service
  class Service < Base
    desc "Show service instance information"
    group :services
    input :instance, :argument => :required,
      :from_given => by_name("service instance", :service_instance),
      :desc => "Service instance to show"
    def service
      display_service_instance(input[:instance])
    end

    private

    def display_service_instance(i)
      if quiet?
        line i.name
      elsif v2?
        plan = i.service_plan
        service = plan.service

        apps = i.service_bindings.collect { |b|
          c(b.app.name, :name)
        }.join(", ")

        line "#{c(i.name, :name)}: #{service.label} #{service.version}"

        indented do
          line "provider: #{c(service.provider, :name)}"
          line "bound to: #{apps}" unless apps.empty?
          line "plan: #{c(plan.name, :name)}"

          indented do
            line "description: #{plan.description}"
          end
        end
      else
        line "#{c(i.name, :name)}: #{i.vendor} #{i.version}"
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
vmc-0.4.7 lib/vmc/cli/service/service.rb
vmc-0.4.6 lib/vmc/cli/service/service.rb
vmc-0.4.5 lib/vmc/cli/service/service.rb
vmc-0.4.4 lib/vmc/cli/service/service.rb
vmc-0.4.3 lib/vmc/cli/service/service.rb