vmc-ng/lib/vmc/cli/app.rb in vmc-0.4.0.beta.77 vs vmc-ng/lib/vmc/cli/app.rb in vmc-0.4.0.beta.78
- old
+ new
@@ -86,12 +86,25 @@
input(:name, :argument => true, :desc => "Application name") {
ask("Name")
}
input :path, :default => ".",
:desc => "Path containing the application"
- input(:url, :desc => "URL bound to app") { |default|
- ask("URL", :default => default)
+ input(:url, :desc => "URL bound to app") { |name|
+ choices = url_choices(name)
+
+ options = {
+ :choices => choices + ["none"],
+ :allow_other => true
+ }
+
+ options[:default] = choices.first if choices.size == 1
+
+ url = ask "URL", options
+
+ unless url == "none"
+ url
+ end
}
input(:memory, :desc => "Memory limit") { |default|
ask("Memory Limit",
:choices => memory_choices,
:allow_other => true,
@@ -467,13 +480,15 @@
file.split("\n").each do |l|
line l
end
end
+ rescue CFoundry::NotFound
+ fail "Invalid path #{b(path)} for app #{b(app.name)}"
rescue CFoundry::APIError => e
if e.error_code == 190001
- fail "Invalid path #{b(path)} for app #{b(app.name)}"
+ fail e.description
else
raise
end
end
@@ -498,13 +513,15 @@
line file.join("/")
end
else
invoke :file, :app => app, :path => path
end
+ rescue CFoundry::NotFound
+ fail "Invalid path #{b(path)} for app #{b(app.name)}"
rescue CFoundry::APIError => e
if e.error_code == 190001
- fail "Invalid path #{b(path)} for app #{b(app.name)}"
+ fail e.description
else
raise
end
end
@@ -938,18 +955,11 @@
app.framework = framework
app.runtime = runtime
app.command = input[:command] if framework.name == "standalone"
- url =
- if framework.name == "standalone"
- if (given = input[:url, "none"]) != "none"
- given
- end
- else
- input[:url, "#{name}.#{target_base}"]
- end
+ url = input[:url, name]
app.urls = [url] if url && !v2?
default_memory = detector.suggested_memory(framework) || 64
app.memory = megabytes(input[:memory, human_mb(default_memory)])
@@ -1242,9 +1252,20 @@
human_size(num * 1024 * 1024, 0)
end
def target_base
client.target.sub(/^https?:\/\/([^\.]+\.)?(.+)\/?/, '\2')
+ end
+
+ def url_choices(name)
+ if v2?
+ client.current_space.domains.sort_by(&:name).collect do |d|
+ # TODO: check availability
+ "#{name}.#{d.name}"
+ end
+ else
+ ["#{name}.#{target_base}"]
+ end
end
def memory_choices(exclude = 0)
info = client.info
used = info[:usage][:memory]