Fixes and improves `service show`’s CLI.
parent
a3c32905ee
commit
479dffc6a0
|
@ -154,23 +154,25 @@ commands.push "status", "Prints the status of services." do |args|
|
||||||
end
|
end
|
||||||
|
|
||||||
commands.push "show", "Shows a service's configuration and state." do |args|
|
commands.push "show", "Shows a service's configuration and state." do |args|
|
||||||
service = Service.all.find do |service|
|
if args.size < 1
|
||||||
unless service.name == args[0]
|
STDERR << "usage: service show <id> [id [...]]\n"
|
||||||
next false
|
next
|
||||||
end
|
|
||||||
|
|
||||||
env = args[1]? || "root"
|
|
||||||
if service.environment.name != env
|
|
||||||
next false
|
|
||||||
end
|
|
||||||
|
|
||||||
true
|
|
||||||
end
|
end
|
||||||
if service
|
|
||||||
puts service.summary
|
args.each do |arg|
|
||||||
else
|
environment_name, service_name = Service.parse_id arg
|
||||||
STDERR << "No such service is registered.\n"
|
|
||||||
exit 2
|
service = Service.all.find do |service|
|
||||||
|
service.name == service_name &&
|
||||||
|
service.environment.name == environment_name
|
||||||
|
end
|
||||||
|
|
||||||
|
if service
|
||||||
|
puts service.summary
|
||||||
|
else
|
||||||
|
STDERR << "No such service is registered.\n"
|
||||||
|
exit 2
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue