vmc-ng/lib/vmc/cli/service.rb in vmc-0.4.0.beta.64 vs vmc-ng/lib/vmc/cli/service.rb in vmc-0.4.0.beta.65
- old
+ new
@@ -2,23 +2,23 @@
module VMC
class Service < CLI
desc "List your service instances"
group :services
- input(:space, :desc => "Show services in given space",
- :from_given => by_name("space")) {
- client.current_space
- }
+ input :space,
+ :from_given => by_name("space"),
+ :default => proc { client.current_space },
+ :desc => "Show services in given space"
input :name, :desc => "Filter by name"
input :service, :desc => "Filter by service type"
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"
+ input :full, :type => :boolean, :default => false,
+ :desc => "Verbose output format"
def services
msg =
if space = input[:space]
"Getting services in #{c(space.name, :name)}"
else
@@ -38,16 +38,37 @@
instances.reject! do |i|
!instance_matches(i, input)
end
- if input[:one_line]
- display_tabular_service_instances(instances)
- else
+ if input[:full]
spaced(instances) do |i|
display_service_instance(i)
end
+ else
+ 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
end
desc "Show service instance information"
@@ -225,12 +246,13 @@
fail "No services." if instances.empty?
ask "Which service instance?", :choices => instances,
:display => proc(&:name)
}
- input(:really, :type => :boolean, :forget => true) { |name, color|
- force? || ask("Really delete #{c(name, color)}?", :default => false)
+ input(:really, :type => :boolean, :forget => true,
+ :default => proc { force? || interact }) { |name, color|
+ ask("Really delete #{c(name, color)}?", :default => false)
}
input :all, :type => :boolean, :default => false,
:desc => "Delete all services"
def delete_service
if input[:all]
@@ -326,34 +348,9 @@
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