vmc-ng/lib/vmc/cli/service.rb in vmc-0.4.0.beta.54 vs vmc-ng/lib/vmc/cli/service.rb in vmc-0.4.0.beta.55
- old
+ new
@@ -9,10 +9,12 @@
input :plan, :desc => "Filter by service plan"
input :provider, :desc => "Filter by service provider"
input :version, :desc => "Filter by service version"
input :app, :desc => "Limit to application's service bindings",
:from_given => by_name("app")
+ input :one_line, :alias => "-l", :type => :boolean, :default => false,
+ :desc => "Single-line tabular format"
def services
instances =
with_progress("Getting service instances") do
client.service_instances(2)
end
@@ -25,12 +27,16 @@
instances.reject! do |i|
!instance_matches(i, input)
end
- spaced(instances) do |i|
- display_service_instance(i)
+ if input[:one_line]
+ display_tabular_service_instances(instances)
+ else
+ spaced(instances) do |i|
+ display_service_instance(i)
+ end
end
end
desc "Show service instance information"
@@ -290,23 +296,52 @@
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 "description: #{service.description}"
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
+
+ def display_tabular_service_instances(instances)
+ table(
+ ["name", "service", "version", v2? && "plan", v2? && "bound apps"],
+ instances.collect { |i|
+ if v2?
+ plan = i.service_plan
+ service = plan.service
+
+ label = service.label
+ version = service.version
+ apps = name_list(i.service_bindings.collect(&:app))
+ else
+ label = i.vendor
+ version = i.version
+ end
+
+ [ c(i.name, :name),
+ label,
+ version,
+ v2? && plan.name,
+ apps
+ ]
+ })
end
def human_list(xs)
if xs.size == 1
xs.first