From 8ff2386dc313c45a929bf41161b6e2802fd9ad82 Mon Sep 17 00:00:00 2001 From: Carl Wilson Date: Wed, 3 Jun 2020 21:43:10 +0100 Subject: [PATCH] FEAT: Piccolo Proof of Concept - short demo showing use of Picolo as a config objectl and - fixed faulty package-info stuff. --- jhove-apps/pom.xml | 6 ++++ jhove-apps/src/main/java/Jhove.java | 10 +++++++ jhove-apps/src/main/java/JhoveConfig.java | 30 +++++++++++++++++++ .../ois/jhove/module/gzip/package-info.java | 2 +- .../ois/jhove/module/warc/package-info.java | 2 +- 5 files changed, 48 insertions(+), 2 deletions(-) create mode 100644 jhove-apps/src/main/java/JhoveConfig.java diff --git a/jhove-apps/pom.xml b/jhove-apps/pom.xml index 416d9ed1a..bf7efd7d1 100644 --- a/jhove-apps/pom.xml +++ b/jhove-apps/pom.xml @@ -65,6 +65,12 @@ junit junit + + + info.picocli + picocli + 4.3.2 + diff --git a/jhove-apps/src/main/java/Jhove.java b/jhove-apps/src/main/java/Jhove.java index 72b289d9e..1b34c3013 100644 --- a/jhove-apps/src/main/java/Jhove.java +++ b/jhove-apps/src/main/java/Jhove.java @@ -24,6 +24,7 @@ import edu.harvard.hul.ois.jhove.JhoveBase; import edu.harvard.hul.ois.jhove.Module; import edu.harvard.hul.ois.jhove.OutputHandler; +import picocli.CommandLine; import java.util.ArrayList; import java.util.List; @@ -60,6 +61,15 @@ public static void main(String [] args) System.exit(ExitCode.INCOMPATIBLE_VM.getReturnCode()); } + // SHORT DEMO and OUT + // Set up config + JhoveConfig config = new JhoveConfig(); + // Parse the args passed + new CommandLine(config).parseArgs(args); + // Test the use of -k for checksumming. + System.out.println("Checksum opt is: " + config.isCheckum); + System.exit(0); + try { // Initialize the application state object. diff --git a/jhove-apps/src/main/java/JhoveConfig.java b/jhove-apps/src/main/java/JhoveConfig.java new file mode 100644 index 000000000..d559a578c --- /dev/null +++ b/jhove-apps/src/main/java/JhoveConfig.java @@ -0,0 +1,30 @@ +/** + * + */ + + +import java.io.File; + +/** + * @author cfw + * + */ +import picocli.CommandLine.Option; +import picocli.CommandLine.Parameters; + +public final class JhoveConfig { + // Something like this + // NOTE the --config and other flag additions + @Option(names = { "-c", "--config" }, + description = "Path to an alternative jhove config file.") + File config; + @Option(names = { "-k", "--checksum" }, + description = "Path to an alternative jhove config file.") + boolean isCheckum; + @Option(names = { "-m", "--module" }, + description = "Name of the JHOVE module to invoke.") + String moduleName; + // I'd like to see us go multi file if we can + @Parameters(arity = "0..*", paramLabel = "FILE", description = "Directories, files or URIs to process.") + File[] toProcess; +} diff --git a/jhove-ext-modules/src/main/java/edu/harvard/hul/ois/jhove/module/gzip/package-info.java b/jhove-ext-modules/src/main/java/edu/harvard/hul/ois/jhove/module/gzip/package-info.java index 722738d5a..be0150ea1 100644 --- a/jhove-ext-modules/src/main/java/edu/harvard/hul/ois/jhove/module/gzip/package-info.java +++ b/jhove-ext-modules/src/main/java/edu/harvard/hul/ois/jhove/module/gzip/package-info.java @@ -10,4 +10,4 @@ *
  • JHOVE home page * */ -package hul.ois.jhove.module.gzip; +package edu.harvard.hul.ois.jhove.module.gzip; diff --git a/jhove-ext-modules/src/main/java/edu/harvard/hul/ois/jhove/module/warc/package-info.java b/jhove-ext-modules/src/main/java/edu/harvard/hul/ois/jhove/module/warc/package-info.java index c918dcb08..3bf6175b8 100644 --- a/jhove-ext-modules/src/main/java/edu/harvard/hul/ois/jhove/module/warc/package-info.java +++ b/jhove-ext-modules/src/main/java/edu/harvard/hul/ois/jhove/module/warc/package-info.java @@ -10,4 +10,4 @@ *
  • JHOVE home page * */ -package hul.ois.jhove.module.warc; +package edu.harvard.hul.ois.jhove.module.warc;