Skip to content

Commit 6feb427

Browse files
authored
Convert argument parser option strings into FilePath for paths (#329)
1 parent c78080a commit 6feb427

File tree

3 files changed

+14
-4
lines changed

3 files changed

+14
-4
lines changed

Sources/Swiftly/Install.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ struct Install: SwiftlyCommand {
6969
written to this file as commands that can be run after the installation.
7070
"""
7171
))
72-
var postInstallFile: String?
72+
var postInstallFile: FilePath?
7373

7474
@OptionGroup var root: GlobalOptions
7575

@@ -156,7 +156,7 @@ struct Install: SwiftlyCommand {
156156
}
157157

158158
try Data(postInstallScript.utf8).write(
159-
to: FilePath(postInstallFile), options: .atomic
159+
to: postInstallFile, options: .atomic
160160
)
161161
}
162162
}

Sources/Swiftly/Swiftly.swift

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,16 @@ import SystemPackage
1010

1111
typealias fs = SwiftlyCore.FileSystem
1212

13+
extension FilePath: ExpressibleByArgument {
14+
public init?(argument: String) {
15+
self.init(argument)
16+
}
17+
18+
public static var defaultCompletionKind: CompletionKind {
19+
CompletionKind.file()
20+
}
21+
}
22+
1323
public struct GlobalOptions: ParsableArguments {
1424
@Flag(name: [.customShort("y"), .long], help: "Disable confirmation prompts by assuming 'yes'")
1525
var assumeYes: Bool = false

Sources/Swiftly/Update.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ struct Update: SwiftlyCommand {
7272
written to this file as commands that can be run after the installation.
7373
"""
7474
))
75-
var postInstallFile: String?
75+
var postInstallFile: FilePath?
7676

7777
private enum CodingKeys: String, CodingKey {
7878
case toolchain, root, verify, postInstallFile
@@ -138,7 +138,7 @@ struct Update: SwiftlyCommand {
138138
""")
139139
}
140140

141-
try Data(postInstallScript.utf8).write(to: FilePath(postInstallFile), options: .atomic)
141+
try Data(postInstallScript.utf8).write(to: postInstallFile, options: .atomic)
142142
}
143143

144144
if pathChanged {

0 commit comments

Comments
 (0)