Skip to content

Commit fc84878

Browse files
authored
Print file URLs without leading file schema (#244)
Swiftly interpolates some file URLs directly into user facing output leading to messages like 'The file `file:///Volumes/...` has been...' which needlessly contains the url schema prefix `file://`. This change updates Swiftly to use URL.path for better user output.
1 parent 2531b9f commit fc84878

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

Sources/MacOSPlatform/MacOS.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,11 +128,11 @@ public struct MacOS: Platform {
128128
let decoder = PropertyListDecoder()
129129
let infoPlist = toolchainDir.appendingPathComponent("Info.plist")
130130
guard let data = try? Data(contentsOf: infoPlist) else {
131-
throw SwiftlyError(message: "could not open \(infoPlist)")
131+
throw SwiftlyError(message: "could not open \(infoPlist.path)")
132132
}
133133

134134
guard let pkgInfo = try? decoder.decode(SwiftPkgInfo.self, from: data) else {
135-
throw SwiftlyError(message: "could not decode plist at \(infoPlist)")
135+
throw SwiftlyError(message: "could not decode plist at \(infoPlist.path)")
136136
}
137137

138138
try FileManager.default.removeItem(at: toolchainDir)

Sources/Swiftly/Use.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ internal struct Use: SwiftlyCommand {
116116
// We don't care in this case if there were any problems with the swift version files, just overwrite it with the new value
117117
try toolchain.name.write(to: versionFile, atomically: true, encoding: .utf8)
118118

119-
message = "The file `\(versionFile)` has been set to `\(toolchain)`"
119+
message = "The file `\(versionFile.path)` has been set to `\(toolchain)`"
120120
} else if let newVersionFile = findNewVersionFile(), !globalDefault {
121121
if !assumeYes {
122122
SwiftlyCore.print("A new file `\(newVersionFile)` will be created to set the new in-use toolchain for this project. Alternatively, you can set your default globally with the `--global-default` flag. Proceed with creating this file?")
@@ -129,7 +129,7 @@ internal struct Use: SwiftlyCommand {
129129

130130
try toolchain.name.write(to: newVersionFile, atomically: true, encoding: .utf8)
131131

132-
message = "The file `\(newVersionFile)` has been set to `\(toolchain)`"
132+
message = "The file `\(newVersionFile.path)` has been set to `\(toolchain)`"
133133
} else {
134134
config.inUse = toolchain
135135
try config.save()

0 commit comments

Comments
 (0)