From 479dffc6a0dbcca58c7defa781ac2e5bb114bb38 Mon Sep 17 00:00:00 2001 From: Luka Vandervelden Date: Fri, 25 Oct 2019 12:28:39 +0200 Subject: [PATCH] =?UTF-8?q?Fixes=20and=20improves=20`service=20show`?= =?UTF-8?q?=E2=80=99s=20CLI.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/service.cr | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/src/service.cr b/src/service.cr index 1c2a568..de89e4f 100644 --- a/src/service.cr +++ b/src/service.cr @@ -154,23 +154,25 @@ commands.push "status", "Prints the status of services." do |args| end commands.push "show", "Shows a service's configuration and state." do |args| - service = Service.all.find do |service| - unless service.name == args[0] - next false - end - - env = args[1]? || "root" - if service.environment.name != env - next false - end - - true + if args.size < 1 + STDERR << "usage: service show [id [...]]\n" + next end - if service - puts service.summary - else - STDERR << "No such service is registered.\n" - exit 2 + + args.each do |arg| + environment_name, service_name = Service.parse_id arg + + 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