diff --git a/Sources/Swiftly/Run.swift b/Sources/Swiftly/Run.swift index 21c1bb2c..9805e19d 100644 --- a/Sources/Swiftly/Run.swift +++ b/Sources/Swiftly/Run.swift @@ -63,7 +63,7 @@ struct Run: SwiftlyCommand { var config = try await Config.load(ctx) // Handle the specific case where help is requested of the run subcommand - if command == ["--help"] { + if command == ["--help"] || command == ["-h"] { throw CleanExit.helpRequest(self) } diff --git a/Tests/SwiftlyTests/RunTests.swift b/Tests/SwiftlyTests/RunTests.swift index 09546e18..4264c0d4 100644 --- a/Tests/SwiftlyTests/RunTests.swift +++ b/Tests/SwiftlyTests/RunTests.swift @@ -1,3 +1,4 @@ +import ArgumentParser import Foundation @testable import Swiftly @testable import SwiftlyCore @@ -84,4 +85,23 @@ import Testing #expect(["swift", "build"] == command) #expect(nil == selector) } + + /// Tests the help functionality of the `run` command + @Test(.testHomeMockedToolchain()) func runHelp() async throws { + // Test --help is handled correctly + do { + try await SwiftlyTests.runCommand(Run.self, ["run", "--help"]) + #expect(false) + } catch { + #expect(error is CleanExit) + } + + // Test -h is handled correctly + do { + try await SwiftlyTests.runCommand(Run.self, ["run", "-h"]) + #expect(false) + } catch { + #expect(error is CleanExit) + } + } }