diff --git a/Sources/Swiftly/Run.swift b/Sources/Swiftly/Run.swift index 32efb0ee..1f163a13 100644 --- a/Sources/Swiftly/Run.swift +++ b/Sources/Swiftly/Run.swift @@ -69,6 +69,11 @@ struct Run: SwiftlyCommand { throw CleanExit.helpRequest(self) } + // Handle the spcific case where version is requested of the run subcommand + if command == ["--version"] { + throw CleanExit.message(String(describing: SwiftlyCore.version)) + } + let (command, selector) = try Self.extractProxyArguments(command: self.command) let toolchain: ToolchainVersion? diff --git a/Tests/SwiftlyTests/RunTests.swift b/Tests/SwiftlyTests/RunTests.swift index dd861c8c..d35cf6e0 100644 --- a/Tests/SwiftlyTests/RunTests.swift +++ b/Tests/SwiftlyTests/RunTests.swift @@ -107,4 +107,15 @@ import Testing #expect(error is CleanExit) } } + + /// Tests the version functionality of the `run` command + @Test(.testHomeMockedToolchain()) func runVersion() async throws { + // Test --version is handled correctly + do { + try await SwiftlyTests.runCommand(Run.self, ["run", "--version"]) + #expect(false) + } catch { + #expect(error is CleanExit) + } + } }