Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Sources/Swiftly/Run.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down
20 changes: 20 additions & 0 deletions Tests/SwiftlyTests/RunTests.swift
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import ArgumentParser
import Foundation
@testable import Swiftly
@testable import SwiftlyCore
Expand Down Expand Up @@ -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)
}
}
}