Skip to content

Commit a45b771

Browse files
committed
command: fix argument parser usage, remove workaround for bool? opts
1 parent 5ff12b1 commit a45b771

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

Sources/SwiftJavaTool/Commands/JExtractCommand.swift

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ extension SwiftJava {
5858
@Option(help: "The directory where generated Java files should be written. Generally used with jextract mode.")
5959
var outputJava: String
6060

61-
@Flag(help: "Some build systems require an output to be present when it was 'expected', even if empty. This is used by the JExtractSwiftPlugin build plugin, but otherwise should not be necessary.")
62-
var writeEmptyFiles: Bool = false
61+
@Flag(inversion: .prefixedNo, help: "Some build systems require an output to be present when it was 'expected', even if empty. This is used by the JExtractSwiftPlugin build plugin, but otherwise should not be necessary.")
62+
var writeEmptyFiles: Bool?
6363

6464
@Option(help: "The mode of generation to use for the output files. Used with jextract mode. By default, unsigned Swift types are imported as their bit-width compatible signed Java counterparts, and annotated using the '@Unsigned' annotation. You may choose the 'wrapGuava' mode in order to import types as class wrapper types (`UnsignedInteger` et al) defined by the Google Guava library's `com.google.common.primitives' package. that ensure complete type-safety with regards to unsigned values, however they incur an allocation and performance overhead.")
6565
var unsignedNumbersMode: JExtractUnsignedIntegerMode?
@@ -82,8 +82,8 @@ extension SwiftJava {
8282
@Option(help: "The mode to use for extracting asynchronous Swift functions. By default async methods are extracted as Java functions returning CompletableFuture.")
8383
var asyncFuncMode: JExtractAsyncFuncMode?
8484

85-
@Flag(help: "By enabling this mode, JExtract will generate Java code that allows you to implement Swift protocols using Java classes. This feature requires disabling the sandbox mode in SwiftPM. This only works in the 'jni' mode.")
86-
var enableJavaCallbacks: Bool = false
85+
@Flag(inversion: .prefixedNo, help: "By enabling this mode, JExtract will generate Java code that allows you to implement Swift protocols using Java classes. This feature requires disabling the SwiftPM Sandbox (!). This feature is onl supported in 'jni' mode.")
86+
var enableJavaCallbacks: Bool?
8787

8888
@Option(help: "If specified, JExtract will output to this file a list of paths to all generated Java source files")
8989
var generatedJavaSourcesListFileOutput: String?
@@ -98,11 +98,7 @@ extension SwiftJava.JExtractCommand {
9898
config.outputJavaDirectory = outputJava
9999
config.outputSwiftDirectory = outputSwift
100100

101-
// @Flag does not support optional, so we check ourself if it is passed
102-
let writeEmptyFiles = CommandLine.arguments.contains("--write-empty-files") ? true : nil
103101
configure(&config.writeEmptyFiles, overrideWith: writeEmptyFiles)
104-
105-
let enableJavaCallbacks = CommandLine.arguments.contains("--enable-java-callbacks") ? true : nil
106102
configure(&config.enableJavaCallbacks, overrideWith: enableJavaCallbacks)
107103

108104
configure(&config.unsignedNumbersMode, overrideWith: self.unsignedNumbersMode)

0 commit comments

Comments
 (0)