From 97e2f29ef373327339b25be3fe66689ebac02138 Mon Sep 17 00:00:00 2001 From: omochimetaru Date: Fri, 12 Apr 2019 16:55:11 +0900 Subject: [PATCH] care empty list --- Sources/toybox/Commands/List.swift | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Sources/toybox/Commands/List.swift b/Sources/toybox/Commands/List.swift index 167fff1..a838e26 100644 --- a/Sources/toybox/Commands/List.swift +++ b/Sources/toybox/Commands/List.swift @@ -18,6 +18,10 @@ struct ListOptions: OptionsProtocol { } private func prettyList(_ playgrounds: [Playground]) -> String { + if playgrounds.isEmpty { + return "" + } + let maxNameCount = playgrounds.max { $0.name.count < $1.name.count }!.name.count let maxPlatformCount = playgrounds.max { $0.platform.rawValue.count < $1.platform.rawValue.count }!.platform.displayName.count let maxContentLengthCount = String(playgrounds.max { $0.contentLength ?? 0 < $1.contentLength ?? 0 }!.contentLength ?? 0).count