Skip to content

Commit 4fab0c0

Browse files
johnbuteJohn Bute
andauthored
fixed quick --version error (#458)
Co-authored-by: John Bute <[email protected]>
1 parent 32b15ab commit 4fab0c0

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

Sources/Swiftly/Run.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,11 @@ struct Run: SwiftlyCommand {
6969
throw CleanExit.helpRequest(self)
7070
}
7171

72+
// Handle the spcific case where version is requested of the run subcommand
73+
if command == ["--version"] {
74+
throw CleanExit.message(String(describing: SwiftlyCore.version))
75+
}
76+
7277
let (command, selector) = try Self.extractProxyArguments(command: self.command)
7378

7479
let toolchain: ToolchainVersion?

Tests/SwiftlyTests/RunTests.swift

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,4 +107,15 @@ import Testing
107107
#expect(error is CleanExit)
108108
}
109109
}
110+
111+
/// Tests the version functionality of the `run` command
112+
@Test(.testHomeMockedToolchain()) func runVersion() async throws {
113+
// Test --version is handled correctly
114+
do {
115+
try await SwiftlyTests.runCommand(Run.self, ["run", "--version"])
116+
#expect(false)
117+
} catch {
118+
#expect(error is CleanExit)
119+
}
120+
}
110121
}

0 commit comments

Comments
 (0)