vmc-ng/lib/vmc/cli/app.rb in vmc-0.4.0.beta.58 vs vmc-ng/lib/vmc/cli/app.rb in vmc-0.4.0.beta.59
- old
+ new
@@ -5,32 +5,33 @@
module VMC
class App < CLI
desc "List your applications"
group :apps
- input :space, :desc => "Show apps in given space",
- :from_given => by_name("space")
+ input(:space, :desc => "Show apps in given space",
+ :from_given => by_name("space")) {
+ client.current_space
+ }
input :name, :desc => "Filter by name regexp"
input :runtime, :desc => "Filter by runtime regexp"
input :framework, :desc => "Filter by framework regexp"
input :url, :desc => "Filter by url regexp"
input :one_line, :alias => "-l", :type => :boolean, :default => false,
:desc => "Single-line tabular format"
def apps
- if space = input[:space] || client.current_space
- apps =
- with_progress("Getting applications in #{c(space.name, :name)}") do
- # depth of 2 for service binding instance names
- space.apps(2)
- end
- else
- apps =
- with_progress("Getting applications") do
- client.apps
- end
- end
+ msg =
+ if space = input[:space]
+ "Getting applications in #{c(space.name, :name)}"
+ else
+ "Getting applications"
+ end
+ apps =
+ with_progress(msg) do
+ client.apps(2)
+ end
+
if apps.empty? and !quiet?
line
line "No applications."
return
end
@@ -51,11 +52,17 @@
[ c(a.name, :name),
app_status(a),
"#{a.total_instances} x #{human_mb(a.memory)}",
v2? && (a.production ? "prod" : "dev"),
a.runtime.name,
- a.urls.size == 1 ? a.url : "#{a.url}, ..."
+ if a.urls.empty?
+ d("none")
+ elsif a.urls.size == 1
+ a.url
+ else
+ "#{a.url}, ..."
+ end
]
})
else
spaced(apps) do |a|
display_app(a)
@@ -91,16 +98,16 @@
input(:instances, :type => :integer,
:desc => "Number of instances to run") {
ask("Instances", :default => 1)
}
input(:framework, :from_given => find_by_name("framework"),
- :desc => "Framework to use") { |choices, default, all, other|
- ask_with_other("Framework", choices, default, all, other)
+ :desc => "Framework to use") { |all, choices, default, other|
+ ask_with_other("Framework", all, choices, default, other)
}
input(:runtime, :from_given => find_by_name("runtime"),
- :desc => "Runtime to use") { |choices, default, all, other|
- ask_with_other("Runtime", choices, default, all, other)
+ :desc => "Runtime to use") { |all, choices, default, other|
+ ask_with_other("Runtime", all, choices, default, other)
}
input(:command, :desc => "Startup command for standalone app") {
ask("Startup command")
}
input :plan, :default => "D100",
@@ -848,13 +855,13 @@
all_runtimes = detector.all_runtimes
if detected_framework = detector.detect_framework
framework = input[
:framework,
+ all_frameworks,
[detected_framework],
detected_framework,
- all_frameworks,
:other
]
else
framework = input[:framework, all_frameworks]
end
@@ -873,13 +880,13 @@
if detected_runtimes.empty?
runtime = input[:runtime, all_runtimes]
else
runtime = input[
:runtime,
+ all_runtimes,
detected_runtimes,
default_runtime,
- all_runtimes,
:other
]
end
@@ -1078,10 +1085,10 @@
# TODO: splat
invoke :delete_service, :instance => instance, :really => true
end
end
- def ask_with_other(message, choices, default, all, other)
+ def ask_with_other(message, all, choices, default, other)
choices = choices.sort_by(&:name)
choices << other if other
opts = {
:choices => choices,