Skip to content

Commit

Permalink
Merge pull request #24 from omochi/empty-list
Browse files Browse the repository at this point in the history
Playgroundが1つも無いときにlistコマンドがクラッシュするバグの修正
  • Loading branch information
giginet committed Apr 12, 2019
2 parents a58eb11 + 05e921d commit 3124f96
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Sources/toybox/Commands/List.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 3124f96

Please sign in to comment.