Skip to content

Commit 9a2b40b

Browse files
authored
command: fix argument parser usage, remove workaround for bool? opts (#487)
1 parent 0eefeab commit 9a2b40b

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 lowest access level of Swift declarations that should be extracted, defaults to 'public'.")
6565
var minimumInputAccessLevelMode: JExtractMinimumAccessLevelMode?
@@ -79,8 +79,8 @@ extension SwiftJava {
7979
@Option(help: "The mode to use for extracting asynchronous Swift functions. By default async methods are extracted as Java functions returning CompletableFuture.")
8080
var asyncFuncMode: JExtractAsyncFuncMode?
8181

82-
@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.")
83-
var enableJavaCallbacks: Bool = false
82+
@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.")
83+
var enableJavaCallbacks: Bool?
8484

8585
@Option(help: "If specified, JExtract will output to this file a list of paths to all generated Java source files")
8686
var generatedJavaSourcesListFileOutput: String?
@@ -95,11 +95,7 @@ extension SwiftJava.JExtractCommand {
9595
config.outputJavaDirectory = outputJava
9696
config.outputSwiftDirectory = outputSwift
9797

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

105101
configure(&config.minimumInputAccessLevelMode, overrideWith: self.minimumInputAccessLevelMode)

0 commit comments

Comments
 (0)