@@ -24,9 +24,12 @@ import SwiftSyntaxBuilder
2424import JavaKitConfigurationShared
2525import JavaKitShared
2626
27- @main
2827struct JavaToSwift : AsyncParsableCommand {
29- static var _commandName : String { " swift-java " }
28+ static var _commandName : String { " java2swift " }
29+
30+ static var configuration = CommandConfiguration (
31+ commandName: Self . _commandName,
32+ abstract: " Generate Swift wrappers for Java code. " )
3033
3134 @Option ( help: " The name of the Swift module into which the resulting Swift types will be generated. " )
3235 var moduleName : String ?
@@ -61,10 +64,10 @@ struct JavaToSwift: AsyncParsableCommand {
6164 @Option ( name: . shortAndLong, help: " The directory in which to output the generated Swift files or the swift-java configuration file. " )
6265 var outputDirectory : String ? = nil
6366
64-
67+
6568 @Option ( name: . shortAndLong, help: " Directory where to write cached values (e.g. swift-java.classpath files) " )
6669 var cacheDirectory : String ? = nil
67-
70+
6871 var effectiveCacheDirectory : String ? {
6972 if let cacheDirectory {
7073 return cacheDirectory
@@ -74,7 +77,7 @@ struct JavaToSwift: AsyncParsableCommand {
7477 return nil
7578 }
7679 }
77-
80+
7881 @Option ( name: . shortAndLong, help: " How to handle an existing swift-java.config; by default 'overwrite' by can be changed to amending a configuration " )
7982 var existingConfig : ExistingConfigFileMode = . overwrite
8083 public enum ExistingConfigFileMode : String , ExpressibleByArgument , Codable {
@@ -168,7 +171,7 @@ struct JavaToSwift: AsyncParsableCommand {
168171 print ( " [info][swift-java] Run: \( CommandLine . arguments. joined ( separator: " " ) ) " )
169172 do {
170173 let config : Configuration
171-
174+
172175 // Determine the mode in which we'll execute.
173176 let toolMode : ToolMode
174177 if jar {
@@ -217,14 +220,14 @@ struct JavaToSwift: AsyncParsableCommand {
217220 let classpathFromEnv = ProcessInfo . processInfo. environment [ " CLASSPATH " ] ? . split ( separator: " : " ) . map ( String . init) ?? [ ]
218221 let classpathFromConfig : [ String ] = config. classpath? . split ( separator: " : " ) . map ( String . init) ?? [ ]
219222 print ( " [debug][swift-java] Base classpath from config: \( classpathFromConfig) " )
220-
223+
221224 var classpathEntries : [ String ] = classpathFromConfig
222-
225+
223226 let swiftJavaCachedModuleClasspath = findSwiftJavaClasspaths (
224227 in: self . effectiveCacheDirectory ?? FileManager . default. currentDirectoryPath)
225228 print ( " [debug][swift-java] Classpath from *.swift-java.classpath files: \( swiftJavaCachedModuleClasspath) " )
226229 classpathEntries += swiftJavaCachedModuleClasspath
227-
230+
228231 if !classpathOptionEntries. isEmpty {
229232 print ( " [debug][swift-java] Classpath from options: \( classpathOptionEntries) " )
230233 classpathEntries += classpathOptionEntries
0 commit comments