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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions Sources/SwiftDriver/Driver/Driver.swift
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ extension Driver.ErrorDiagnostics: CustomStringConvertible {
/// The Swift driver.
public struct Driver {
public enum Error: Swift.Error, Equatable, DiagnosticData {
case unknownOrMissingSubcommand(String)
case unknownOrMissingSubcommand(String, String?)
case invalidDriverName(String)
case invalidInput(String)
case noInputFiles
Expand Down Expand Up @@ -82,7 +82,10 @@ public struct Driver {

public var description: String {
switch self {
case .unknownOrMissingSubcommand(let subcommand):
case .unknownOrMissingSubcommand(let subcommand, let directory):
if let directory {
return "unknown or missing subcommand '\(subcommand)' in '\(directory)'"
}
return "unknown or missing subcommand '\(subcommand)'"
case .invalidDriverName(let driverName):
return "invalid driver name: \(driverName)"
Expand Down
8 changes: 6 additions & 2 deletions Sources/swift-driver/main.swift
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,11 @@ do {
let legacyDriverCommand = [path] + CommandLine.arguments[1...]
try exec(path: path, args: legacyDriverCommand)
} else {
throw Driver.Error.unknownOrMissingSubcommand(legacyExecutablePath.lastPathComponent)
throw Driver.Error.unknownOrMissingSubcommand(
legacyExecutablePath.lastPathComponent,
legacyExecutablePath
.deletingLastPathComponent()
.withUnsafeFileSystemRepresentation { String(cString: $0!) })
}
}

Expand All @@ -127,7 +131,7 @@ do {

guard let subcommandPath = subcommandPath,
localFileSystem.exists(subcommandPath) else {
throw Driver.Error.unknownOrMissingSubcommand(subcommand)
throw Driver.Error.unknownOrMissingSubcommand(subcommand, nil)
}

// Pass the full path to subcommand executable.
Expand Down