Skip to content

Commit

Permalink
Merge pull request #966 from Carthage/fix-platform-list-with-spaces
Browse files Browse the repository at this point in the history
Allow multiple platform list to contain spaces
  • Loading branch information
mdiep committed Dec 4, 2015
2 parents 38cafc2 + c4002fc commit de21a64
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions Source/carthage/Build.swift
Original file line number Diff line number Diff line change
Expand Up @@ -303,28 +303,28 @@ extension BuildPlatform: ArgumentType {
]

public static func fromString(string: String) -> BuildPlatform? {
let commaSeparated = string.characters.split(allowEmptySlices: false) { $0 == "," }.map(String.init)
let tokens = string.characters
.split(allowEmptySlices: false) { $0 == "," || $0 == " " }
.map(String.init)

let findBuildPlatform: String -> BuildPlatform? = { string in
for (key, platform) in self.acceptedStrings {
if string.caseInsensitiveCompare(key) == .OrderedSame {
return platform
}
}
return nil
return self.acceptedStrings.lazy
.filter { key, _ in string.caseInsensitiveCompare(key) == .OrderedSame }
.map { _, platform in platform }
.first
}

switch commaSeparated.count {
switch tokens.count {
case 0:
return nil

case 1:
return findBuildPlatform(commaSeparated[0])
return findBuildPlatform(tokens[0])

default:
var buildPlatforms = [BuildPlatform]()
for string in commaSeparated {
if let found = findBuildPlatform(string) where found != .All {
for token in tokens {
if let found = findBuildPlatform(token) where found != .All {
buildPlatforms.append(found)
} else {
// Reject if an invalid value is included in the comma-
Expand Down

0 comments on commit de21a64

Please sign in to comment.