@@ -54,7 +54,7 @@ struct JSONOptions: ParsableArguments {
54
54
var json : Bool = false
55
55
}
56
56
57
- public struct SwiftPackageCollectionsTool : ParsableCommand {
57
+ public struct SwiftPackageCollectionsTool : AsyncParsableCommand {
58
58
public static var configuration = CommandConfiguration (
59
59
commandName: " package-collection " ,
60
60
_superCommandName: " swift " ,
@@ -76,7 +76,7 @@ public struct SwiftPackageCollectionsTool: ParsableCommand {
76
76
77
77
// MARK: Collections
78
78
79
- struct List : SwiftCommand {
79
+ struct List : AsyncSwiftCommand {
80
80
static let configuration = CommandConfiguration ( abstract: " List configured collections " )
81
81
82
82
@OptionGroup
@@ -85,9 +85,9 @@ public struct SwiftPackageCollectionsTool: ParsableCommand {
85
85
@OptionGroup ( visibility: . hidden)
86
86
var globalOptions : GlobalOptions
87
87
88
- func run( _ swiftTool: SwiftTool ) throws {
89
- let collections = try with ( swiftTool) { collections in
90
- try temp_await { collections. listCollections ( identifiers: nil , callback : $0 ) }
88
+ func run( _ swiftTool: SwiftTool ) async throws {
89
+ let collections = try await with ( swiftTool) { collections in
90
+ try await collections. listCollections ( identifiers: nil )
91
91
}
92
92
93
93
if self . jsonOptions. json {
@@ -100,21 +100,21 @@ public struct SwiftPackageCollectionsTool: ParsableCommand {
100
100
}
101
101
}
102
102
103
- struct Refresh : SwiftCommand {
103
+ struct Refresh : AsyncSwiftCommand {
104
104
static let configuration = CommandConfiguration ( abstract: " Refresh configured collections " )
105
105
106
106
@OptionGroup ( visibility: . hidden)
107
107
var globalOptions : GlobalOptions
108
108
109
- func run( _ swiftTool: SwiftTool ) throws {
110
- let collections = try with ( swiftTool) { collections in
111
- try temp_await { collections. refreshCollections ( callback : $0 ) }
109
+ func run( _ swiftTool: SwiftTool ) async throws {
110
+ let collections = try await with ( swiftTool) { collections in
111
+ try await collections. refreshCollections ( )
112
112
}
113
113
print ( " Refreshed \( collections. count) configured package collection \( collections. count == 1 ? " " : " s " ) . " )
114
114
}
115
115
}
116
116
117
- struct Add : SwiftCommand {
117
+ struct Add : AsyncSwiftCommand {
118
118
static let configuration = CommandConfiguration ( abstract: " Add a new collection " )
119
119
120
120
@Argument ( help: " URL of the collection to add " )
@@ -132,20 +132,15 @@ public struct SwiftPackageCollectionsTool: ParsableCommand {
132
132
@OptionGroup ( visibility: . hidden)
133
133
var globalOptions : GlobalOptions
134
134
135
- func run( _ swiftTool: SwiftTool ) throws {
135
+ func run( _ swiftTool: SwiftTool ) async throws {
136
136
let collectionURL = try url ( self . collectionURL)
137
137
138
138
let source = PackageCollectionsModel . CollectionSource ( type: . json, url: collectionURL, skipSignatureCheck: self . skipSignatureCheck)
139
- let collection : PackageCollectionsModel . Collection = try with ( swiftTool) { collections in
139
+ let collection : PackageCollectionsModel . Collection = try await with ( swiftTool) { collections in
140
140
do {
141
141
let userTrusted = self . trustUnsigned
142
- return try temp_await {
143
- collections. addCollection (
144
- source,
145
- order: order,
146
- trustConfirmationProvider: { _, callback in callback ( userTrusted) } ,
147
- callback: $0
148
- )
142
+ return try await collections. addCollection ( source, order: order) { _, callback in
143
+ callback ( userTrusted)
149
144
}
150
145
} catch PackageCollectionError . trustConfirmationRequired , PackageCollectionError. untrusted {
151
146
throw CollectionsError . unsigned
@@ -162,7 +157,7 @@ public struct SwiftPackageCollectionsTool: ParsableCommand {
162
157
}
163
158
}
164
159
165
- struct Remove : SwiftCommand {
160
+ struct Remove : AsyncSwiftCommand {
166
161
static let configuration = CommandConfiguration ( abstract: " Remove a configured collection " )
167
162
168
163
@Argument ( help: " URL of the collection to remove " )
@@ -171,13 +166,13 @@ public struct SwiftPackageCollectionsTool: ParsableCommand {
171
166
@OptionGroup ( visibility: . hidden)
172
167
var globalOptions : GlobalOptions
173
168
174
- func run( _ swiftTool: SwiftTool ) throws {
169
+ func run( _ swiftTool: SwiftTool ) async throws {
175
170
let collectionURL = try url ( self . collectionURL)
176
171
177
172
let source = PackageCollectionsModel . CollectionSource ( type: . json, url: collectionURL)
178
- try with ( swiftTool) { collections in
179
- let collection = try temp_await { collections. getCollection ( source, callback : $0 ) }
180
- _ = try temp_await { collections. removeCollection ( source, callback : $0 ) }
173
+ try await with ( swiftTool) { collections in
174
+ let collection = try await collections. getCollection ( source)
175
+ _ = try await collections. removeCollection ( source)
181
176
print ( " Removed \" \( collection. name) \" from your package collections. " )
182
177
}
183
178
}
@@ -190,7 +185,7 @@ public struct SwiftPackageCollectionsTool: ParsableCommand {
190
185
case module
191
186
}
192
187
193
- struct Search : SwiftCommand {
188
+ struct Search : AsyncSwiftCommand {
194
189
static var configuration = CommandConfiguration ( abstract: " Search for packages by keywords or module names " )
195
190
196
191
@OptionGroup
@@ -205,11 +200,11 @@ public struct SwiftPackageCollectionsTool: ParsableCommand {
205
200
@OptionGroup ( visibility: . hidden)
206
201
var globalOptions : GlobalOptions
207
202
208
- func run( _ swiftTool: SwiftTool ) throws {
209
- try with ( swiftTool) { collections in
203
+ func run( _ swiftTool: SwiftTool ) async throws {
204
+ try await with ( swiftTool) { collections in
210
205
switch searchMethod {
211
206
case . keywords:
212
- let results = try temp_await { collections. findPackages ( searchQuery, collections: nil , callback : $0 ) }
207
+ let results = try await collections. findPackages ( searchQuery, collections: nil )
213
208
214
209
if jsonOptions. json {
215
210
try JSONEncoder . makeWithDefaults ( ) . print ( results. items)
@@ -220,7 +215,7 @@ public struct SwiftPackageCollectionsTool: ParsableCommand {
220
215
}
221
216
222
217
case . module:
223
- let results = try temp_await { collections. findTargets ( searchQuery, searchType: . exactMatch, collections: nil , callback : $0 ) }
218
+ let results = try await collections. findTargets ( searchQuery, searchType: . exactMatch, collections: nil )
224
219
225
220
let packages = Set ( results. items. flatMap { $0. packages } )
226
221
if jsonOptions. json {
@@ -237,7 +232,7 @@ public struct SwiftPackageCollectionsTool: ParsableCommand {
237
232
238
233
// MARK: Packages
239
234
240
- struct Describe : SwiftCommand {
235
+ struct Describe : AsyncSwiftCommand {
241
236
static var configuration = CommandConfiguration ( abstract: " Get metadata for a collection or a package included in an imported collection " )
242
237
243
238
@OptionGroup
@@ -287,12 +282,12 @@ public struct SwiftPackageCollectionsTool: ParsableCommand {
287
282
"""
288
283
}
289
284
290
- func run( _ swiftTool: SwiftTool ) throws {
291
- try with ( swiftTool) { collections in
285
+ func run( _ swiftTool: SwiftTool ) async throws {
286
+ try await with ( swiftTool) { collections in
292
287
let identity = PackageIdentity ( urlString: self . packageURL)
293
288
294
289
do { // assume URL is for a package in an imported collection
295
- let result = try temp_await { collections. getPackageMetadata ( identity: identity, location: self . packageURL, callback : $0 ) }
290
+ let result = try await collections. getPackageMetadata ( identity: identity, location: self . packageURL)
296
291
297
292
if let versionString = version {
298
293
guard let version = TSCUtility . Version ( versionString) , let result = result. package . versions. first ( where: { $0. version == version } ) , let printedResult = printVersion ( result) else {
@@ -333,7 +328,7 @@ public struct SwiftPackageCollectionsTool: ParsableCommand {
333
328
334
329
do {
335
330
let source = PackageCollectionsModel . CollectionSource ( type: . json, url: collectionURL, skipSignatureCheck: self . skipSignatureCheck)
336
- let collection = try temp_await { collections. getCollection ( source, callback : $0 ) }
331
+ let collection = try await collections. getCollection ( source)
337
332
338
333
let description = optionalRow ( " Description " , collection. overview)
339
334
let keywords = optionalRow ( " Keywords " , collection. keywords? . joined ( separator: " , " ) )
@@ -386,7 +381,7 @@ private extension JSONEncoder {
386
381
}
387
382
388
383
private extension ParsableCommand {
389
- func with< T> ( _ swiftTool: SwiftTool , handler: ( _ collections: PackageCollectionsProtocol ) throws -> T ) throws -> T {
384
+ func with< T> ( _ swiftTool: SwiftTool , handler: ( _ collections: PackageCollectionsProtocol ) async throws -> T ) async throws -> T {
390
385
_ = try ? swiftTool. getActiveWorkspace ( emitDeprecatedConfigurationWarning: true )
391
386
let collections = PackageCollections (
392
387
configuration: . init(
@@ -404,7 +399,7 @@ private extension ParsableCommand {
404
399
}
405
400
}
406
401
407
- return try handler ( collections)
402
+ return try await handler ( collections)
408
403
}
409
404
410
405
func url( _ urlString: String ) throws -> URL {
0 commit comments