Skip to content

Commit fbebbe4

Browse files
authored
Merge pull request #257 from ktoso/wip-dont-crash-on-zero-args-cli
2 parents 569a283 + 3913ed8 commit fbebbe4

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

Sources/SwiftJavaTool/SwiftJava.swift

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,12 @@ struct SwiftJava: AsyncParsableCommand {
186186
}
187187

188188
mutating func run() async {
189+
guard CommandLine.arguments.count > 1 else {
190+
// there's no "default" command, print USAGE when no arguments/parameters are passed.
191+
print("Must specify run mode.\n\(Self.helpMessage())")
192+
return
193+
}
194+
189195
print("[info][swift-java] Run: \(CommandLine.arguments.joined(separator: " "))")
190196
print("[info][swift-java] Current work directory: \(URL(fileURLWithPath: "."))")
191197
print("[info][swift-java] Module base directory: \(moduleBaseDir)")
@@ -230,7 +236,7 @@ struct SwiftJava: AsyncParsableCommand {
230236
toolMode = .configuration(extraClasspath: input)
231237
} else if fetch {
232238
guard let input else {
233-
fatalError("Mode -jar requires <input> path\n\(Self.helpMessage())")
239+
fatalError("Mode 'fetch' requires <input> path\n\(Self.helpMessage())")
234240
}
235241
config = try JavaTranslator.readConfiguration(from: URL(fileURLWithPath: input))
236242
guard let dependencies = config.dependencies else {

0 commit comments

Comments
 (0)