11import _StringProcessing
22import ArgumentParser
33import Foundation
4- import TSCBasic
4+ @ preconcurrency import TSCBasic
55import TSCUtility
66
77import SwiftlyCore
88
99struct Install : SwiftlyCommand {
10- public static var configuration = CommandConfiguration (
10+ public static let configuration = CommandConfiguration (
1111 abstract: " Install a new toolchain. "
1212 )
1313
@@ -120,7 +120,7 @@ struct Install: SwiftlyCommand {
120120
121121 // Fish doesn't cache its path, so this instruction is not necessary.
122122 if pathChanged && !shell. hasSuffix ( " fish " ) {
123- ctx. print ( """
123+ await ctx. print ( """
124124 NOTE: Swiftly has updated some elements in your path and your shell may not yet be
125125 aware of the changes. You can update your shell's environment by running
126126
@@ -157,7 +157,7 @@ struct Install: SwiftlyCommand {
157157 assumeYes: Bool
158158 ) async throws -> ( postInstall: String ? , pathChanged: Bool ) {
159159 guard !config. installedToolchains. contains ( version) else {
160- ctx. print ( " \( version) is already installed. " )
160+ await ctx. print ( " \( version) is already installed. " )
161161 return ( nil , false )
162162 }
163163
@@ -166,7 +166,7 @@ struct Install: SwiftlyCommand {
166166 // script for the user to run afterwards.
167167 let postInstallScript = try await Swiftly . currentPlatform. verifySystemPrerequisitesForInstall ( ctx, platformName: config. platform. name, version: version, requireSignatureValidation: verifySignature)
168168
169- ctx. print ( " Installing \( version) " )
169+ await ctx. print ( " Installing \( version) " )
170170
171171 let tmpFile = Swiftly . currentPlatform. getTempFilePath ( )
172172 FileManager . default. createFile ( atPath: tmpFile. path, contents: nil )
@@ -258,7 +258,7 @@ struct Install: SwiftlyCommand {
258258 )
259259 }
260260
261- try Swiftly . currentPlatform. install ( ctx, from: tmpFile, version: version, verbose: verbose)
261+ try await Swiftly . currentPlatform. install ( ctx, from: tmpFile, version: version, verbose: verbose)
262262
263263 var pathChanged = false
264264
@@ -279,19 +279,19 @@ struct Install: SwiftlyCommand {
279279
280280 let overwrite = Set ( toolchainBinDirContents) . subtracting ( existingProxies) . intersection ( swiftlyBinDirContents)
281281 if !overwrite. isEmpty && !assumeYes {
282- ctx. print ( " The following existing executables will be overwritten: " )
282+ await ctx. print ( " The following existing executables will be overwritten: " )
283283
284284 for executable in overwrite {
285- ctx. print ( " \( swiftlyBinDir. appendingPathComponent ( executable) . path) " )
285+ await ctx. print ( " \( swiftlyBinDir. appendingPathComponent ( executable) . path) " )
286286 }
287287
288- guard ctx. promptForConfirmation ( defaultBehavior: false ) else {
288+ guard await ctx. promptForConfirmation ( defaultBehavior: false ) else {
289289 throw SwiftlyError ( message: " Toolchain installation has been cancelled " )
290290 }
291291 }
292292
293293 if verbose {
294- ctx. print ( " Setting up toolchain proxies... " )
294+ await ctx. print ( " Setting up toolchain proxies... " )
295295 }
296296
297297 let proxiesToCreate = Set ( toolchainBinDirContents) . subtracting ( swiftlyBinDirContents) . union ( overwrite)
@@ -327,18 +327,18 @@ struct Install: SwiftlyCommand {
327327 if config. inUse == nil {
328328 config. inUse = version
329329 try config. save ( ctx)
330- ctx. print ( " The global default toolchain has been set to ` \( version) ` " )
330+ await ctx. print ( " The global default toolchain has been set to ` \( version) ` " )
331331 }
332332
333- ctx. print ( " \( version) installed successfully! " )
333+ await ctx. print ( " \( version) installed successfully! " )
334334 return ( postInstallScript, pathChanged)
335335 }
336336
337337 /// Utilize the swift.org API along with the provided selector to select a toolchain for install.
338338 public static func resolve( _ ctx: SwiftlyCoreContext , config: Config , selector: ToolchainSelector ) async throws -> ToolchainVersion {
339339 switch selector {
340340 case . latest:
341- ctx. print ( " Fetching the latest stable Swift release... " )
341+ await ctx. print ( " Fetching the latest stable Swift release... " )
342342
343343 guard let release = try await ctx. httpClient. getReleaseToolchains ( platform: config. platform, limit: 1 ) . first else {
344344 throw SwiftlyError ( message: " couldn't get latest releases " )
@@ -356,7 +356,7 @@ struct Install: SwiftlyCommand {
356356 return . stable( ToolchainVersion . StableRelease ( major: major, minor: minor, patch: patch) )
357357 }
358358
359- ctx. print ( " Fetching the latest stable Swift \( major) . \( minor) release... " )
359+ await ctx. print ( " Fetching the latest stable Swift \( major) . \( minor) release... " )
360360 // If a patch was not provided, perform a lookup to get the latest patch release
361361 // of the provided major/minor version pair.
362362 let toolchain = try await ctx. httpClient. getReleaseToolchains ( platform: config. platform, limit: 1 ) { release in
@@ -374,7 +374,7 @@ struct Install: SwiftlyCommand {
374374 return ToolchainVersion ( snapshotBranch: branch, date: date)
375375 }
376376
377- ctx. print ( " Fetching the latest \( branch) branch snapshot... " )
377+ await ctx. print ( " Fetching the latest \( branch) branch snapshot... " )
378378
379379 // If a date was not provided, perform a lookup to find the most recent snapshot
380380 // for the given branch.
0 commit comments