aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main/java/eu/mulk/aendggner/AendGgner.java29
-rw-r--r--src/main/java/module-info.java3
2 files changed, 26 insertions, 6 deletions
diff --git a/src/main/java/eu/mulk/aendggner/AendGgner.java b/src/main/java/eu/mulk/aendggner/AendGgner.java
index 618f36f..e510efb 100644
--- a/src/main/java/eu/mulk/aendggner/AendGgner.java
+++ b/src/main/java/eu/mulk/aendggner/AendGgner.java
@@ -1,7 +1,13 @@
package eu.mulk.aendggner;
-import java.io.File;
+import java.io.IOException;
+import java.nio.file.Path;
+import java.util.List;
import java.util.concurrent.Callable;
+import org.apache.tika.config.TikaConfig;
+import org.apache.tika.exception.TikaException;
+import org.apache.tika.io.TikaInputStream;
+import org.apache.tika.metadata.Metadata;
import picocli.CommandLine;
import picocli.CommandLine.Command;
import picocli.CommandLine.Parameters;
@@ -14,10 +20,10 @@ import picocli.CommandLine.Parameters;
public class AendGgner implements Callable<Integer> {
@Parameters(index = "0", description = "The base text to modify.")
- private File baseFile;
+ private Path baseFile;
- @Parameters(index = "1", description = "The diff relative to the base text.")
- private File diffFile;
+ @Parameters(arity = "*", description = "The diff relative to the base text.")
+ private List<Path> patches;
public static void main(String... args) {
int exitCode = new CommandLine(new AendGgner()).execute(args);
@@ -25,8 +31,19 @@ public class AendGgner implements Callable<Integer> {
}
@Override
- public final Integer call() {
- System.out.println("Hi.");
+ public final Integer call() throws TikaException, IOException {
+ var tika = new TikaConfig();
+
+ for (var file : patches) {
+ var metadata = new Metadata();
+ metadata.set(Metadata.RESOURCE_NAME_KEY, file.toString());
+ try (var is = TikaInputStream.get(file)) {
+ var mimetype = tika.getDetector().detect(
+ TikaInputStream.get(file), metadata);
+ System.out.printf("File %s is %s.\n", file, mimetype);
+ }
+ }
+
return 0;
}
}
diff --git a/src/main/java/module-info.java b/src/main/java/module-info.java
index e7d9c77..dbe7d62 100644
--- a/src/main/java/module-info.java
+++ b/src/main/java/module-info.java
@@ -1,3 +1,6 @@
module aendggner {
requires info.picocli;
+ requires org.apache.tika.core;
+ requires java.sql;
+ opens eu.mulk.aendggner;
}