@@ -18,7 +18,6 @@ import TSCUtility
18
18
private enum CollectionsError : Swift . Error {
19
19
case invalidArgument( String )
20
20
case invalidVersionString( String )
21
- case noCollectionMatchingURL( String )
22
21
}
23
22
24
23
extension CollectionsError : CustomStringConvertible {
@@ -28,8 +27,6 @@ extension CollectionsError: CustomStringConvertible {
28
27
return " invalid argument ' \( argumentName) ' "
29
28
case . invalidVersionString( let versionString) :
30
29
return " invalid version string ' \( versionString) ' "
31
- case . noCollectionMatchingURL( let url) :
32
- return " no collection matching URL ' \( url) ' "
33
30
}
34
31
}
35
32
}
@@ -169,12 +166,8 @@ public struct SwiftPackageCollectionsTool: ParsableCommand {
169
166
throw CollectionsError . invalidArgument ( " collectionUrl " )
170
167
}
171
168
172
- let collections = try tsc_await { self . collections. listCollections ( identifiers: nil , in: profileOptions. usedProfile, callback: $0) }
173
169
let source = PackageCollectionsModel . CollectionSource ( type: . feed, url: collectionUrl)
174
-
175
- guard let collection = collections. first ( where: { $0. source == source } ) else {
176
- throw CollectionsError . noCollectionMatchingURL ( collectionUrl. absoluteString)
177
- }
170
+ let collection = try tsc_await { self . collections. getCollection ( source, callback: $0) }
178
171
179
172
_ = try tsc_await { self . collections. removeCollection ( source, from: profileOptions. usedProfile, callback: $0) }
180
173
print ( " Removed \" \( collection. name) \" from your package collections. " )
@@ -195,12 +188,8 @@ public struct SwiftPackageCollectionsTool: ParsableCommand {
195
188
throw CollectionsError . invalidArgument ( " collectionUrl " )
196
189
}
197
190
198
- let collections = try tsc_await { self . collections. listCollections ( identifiers: nil , in: profileOptions. usedProfile, callback: $0) }
199
191
let source = PackageCollectionsModel . CollectionSource ( type: . feed, url: collectionUrl)
200
-
201
- guard let collection = collections. first ( where: { $0. source == source } ) else {
202
- throw CollectionsError . noCollectionMatchingURL ( collectionUrl. absoluteString)
203
- }
192
+ let collection = try tsc_await { self . collections. getCollection ( source, callback: $0) }
204
193
205
194
let description = optionalRow ( " Description " , collection. description)
206
195
let keywords = optionalRow ( " Keywords " , collection. keywords? . joined ( separator: " , " ) )
@@ -251,10 +240,9 @@ public struct SwiftPackageCollectionsTool: ParsableCommand {
251
240
case . module:
252
241
let results = try tsc_await { collections. findTargets ( searchQuery, searchType: . exactMatch, collections: nil , profile: profileOptions. usedProfile, callback: $0) }
253
242
254
- results. items. forEach {
255
- $0. packages. forEach {
256
- print ( " \( $0. repository. url) : \( $0. description ?? " " ) " )
257
- }
243
+ let packages = Set ( results. items. flatMap { $0. packages } )
244
+ packages. forEach {
245
+ print ( " \( $0. repository. url) : \( $0. description ?? " " ) " )
258
246
}
259
247
}
260
248
}
0 commit comments