Improved `service status` a bit.

master
Luka Vandervelden 4 years ago
parent b202aa2b5c
commit cd6fd4c81f

@ -343,12 +343,22 @@ class Service
end
def summary
"Name: #{name}\n" +
"Environment: #{environment.name} (#{environment.type.to_s.downcase})\n" +
"%-16s #{name.colorize(:white).to_s}\n" % "Name:" +
"%-16s #{environment.name.colorize(:white).to_s} (#{environment.type.to_s.downcase})\n" % "Environment:" +
(
if provides.size > 0
"Provides:\n" +
(provides.map { |x| " - " + x.token + "\n" }).join
(provides.map { |x|
consumers = get_consumers(x.token)
consumers_string = if consumers.size > 0
consumers.map(&.full_id.colorize(:green).to_s).join ", "
else
"n/a".colorize(:yellow).to_s
end
" - %-12s #{consumers_string}\n" % "#{x.token}:"
}).join
else
""
end
@ -358,13 +368,26 @@ class Service
"Consumes:\n" +
(@reference.consumes.map { |x|
provider = @providers[x.token]?
if provider
" - #{x.token} (from #{provider.id})\n"
provider_string = if provider
provider.full_id.colorize(:green).to_s
elsif x.optional
"n/a".colorize(:yellow).to_s
else
" - #{x.token} " +
"(NOT CURRENTLY PROVIDED)".colorize(:red).to_s +
"\n"
"MISSING".colorize(:red).to_s
end
" - %-12s #{provider_string}\n" % x.token
}).join
else
""
end
) +
(
if @ports.size > 0
"Ports:\n" +
(@ports.map { |name, number|
" - %-12s #{number.colorize(:magenta).to_s}\n" % "#{name}:"
}).join
else
""

Loading…
Cancel
Save