Introduce incremental-krill

Change-Id: Ib46f635abfbfc30bb415ad0a3c7cc96559326def
diff --git a/app/src/main/kotlin/de/ids_mannheim/korapxmltools/KorapXmlTool.kt b/app/src/main/kotlin/de/ids_mannheim/korapxmltools/KorapXmlTool.kt
index 2f02e59..6825c23 100644
--- a/app/src/main/kotlin/de/ids_mannheim/korapxmltools/KorapXmlTool.kt
+++ b/app/src/main/kotlin/de/ids_mannheim/korapxmltools/KorapXmlTool.kt
@@ -213,6 +213,13 @@
     var sequentialInZip: Boolean = false
 
     @Option(
+        names = ["--incremental-krill"],
+        description = ["Enable incremental Krill output (output texts as soon as they have all expected foundries). " +
+                      "Works best when all texts appear in all annotation ZIPs. Default: false."]
+    )
+    var incrementalKrill: Boolean = false
+
+    @Option(
         names = ["--overwrite", "-o"],
         description = ["Overwrite existing files"]
     )
@@ -842,12 +849,11 @@
         }
         logZipProgress(zipFilePath)
 
-        // For Krill format, check if any texts are now complete and output them
-        // TODO: Re-enable incremental output after fixing edge cases with incomplete texts
-        // if (outputFormat == OutputFormat.KRILL) {
-        //     processedFoundries.add(foundry)
-        //     checkAndOutputCompleteTexts()
-        // }
+        // For Krill format with incremental mode, check if any texts are now complete and output them
+        if (outputFormat == OutputFormat.KRILL && incrementalKrill) {
+            processedFoundries.add(foundry)
+            checkAndOutputCompleteTexts()
+        }
     }
 
     private fun processZipFileSequentially(zipFilePath: String, foundry: String = "base") {
@@ -886,12 +892,11 @@
         }
         logZipProgress(zipFilePath)
 
-        // For Krill format, check if any texts are now complete and output them
-        // TODO: Re-enable incremental output after fixing edge cases with incomplete texts
-        // if (outputFormat == OutputFormat.KRILL) {
-        //     processedFoundries.add(foundry)
-        //     checkAndOutputCompleteTexts()
-        // }
+        // For Krill format with incremental mode, check if any texts are now complete and output them
+        if (outputFormat == OutputFormat.KRILL && incrementalKrill) {
+            processedFoundries.add(foundry)
+            checkAndOutputCompleteTexts()
+        }
     }
 
     private fun logZipProgress(zipFilePath: String) {