Skip to content

Commit 4a030e1

Browse files
authored
Fix swiftly run -h to show help message (#452)
1 parent 91f1228 commit 4a030e1

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

Sources/Swiftly/Run.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ struct Run: SwiftlyCommand {
6363
var config = try await Config.load(ctx)
6464

6565
// Handle the specific case where help is requested of the run subcommand
66-
if command == ["--help"] {
66+
if command == ["--help"] || command == ["-h"] {
6767
throw CleanExit.helpRequest(self)
6868
}
6969

Tests/SwiftlyTests/RunTests.swift

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import ArgumentParser
12
import Foundation
23
@testable import Swiftly
34
@testable import SwiftlyCore
@@ -84,4 +85,23 @@ import Testing
8485
#expect(["swift", "build"] == command)
8586
#expect(nil == selector)
8687
}
88+
89+
/// Tests the help functionality of the `run` command
90+
@Test(.testHomeMockedToolchain()) func runHelp() async throws {
91+
// Test --help is handled correctly
92+
do {
93+
try await SwiftlyTests.runCommand(Run.self, ["run", "--help"])
94+
#expect(false)
95+
} catch {
96+
#expect(error is CleanExit)
97+
}
98+
99+
// Test -h is handled correctly
100+
do {
101+
try await SwiftlyTests.runCommand(Run.self, ["run", "-h"])
102+
#expect(false)
103+
} catch {
104+
#expect(error is CleanExit)
105+
}
106+
}
87107
}

0 commit comments

Comments
 (0)