From b7a775c8b243f3a3a786625a94fa23c303ec992c Mon Sep 17 00:00:00 2001 From: Erlend Klakegg Bergheim Date: Mon, 31 Aug 2015 07:32:09 +0200 Subject: [PATCH] Minor refactoring in validator-repo. --- CHANGELOG.md | 3 +- validator-repo/pom.xml | 2 +- .../main/java/no/difi/vefa/validator/Cli.java | 29 +++++++++++++++++++ .../java/no/difi/vefa/validator/Repo.java | 12 -------- 4 files changed, 32 insertions(+), 14 deletions(-) create mode 100644 validator-repo/src/main/java/no/difi/vefa/validator/Cli.java diff --git a/CHANGELOG.md b/CHANGELOG.md index e04faf71..a2ce38e8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,12 +2,13 @@ ## Next release -* Allow tracing successful test. +* Allow tracing successful tests. * Adding FlagType.SUCCESS in API. * Added more logging. * Updating version of no.difi.commons:commons-schematron. * Functionality to sign validation artifacts defined by parameters. * Fixing UTF-8 thing in presentation of rendered documents in sample application. +* Allow override of implementations of checker og renderer to use. ## 2.0.0-RC2 diff --git a/validator-repo/pom.xml b/validator-repo/pom.xml index 8d844f38..f4cd5f92 100644 --- a/validator-repo/pom.xml +++ b/validator-repo/pom.xml @@ -85,7 +85,7 @@ - no.difi.vefa.validator.Repo + no.difi.vefa.validator.Cli diff --git a/validator-repo/src/main/java/no/difi/vefa/validator/Cli.java b/validator-repo/src/main/java/no/difi/vefa/validator/Cli.java new file mode 100644 index 00000000..4f761756 --- /dev/null +++ b/validator-repo/src/main/java/no/difi/vefa/validator/Cli.java @@ -0,0 +1,29 @@ +package no.difi.vefa.validator; + +import org.apache.commons.cli.*; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.nio.file.Paths; + +public class Cli { + + private static Logger logger = LoggerFactory.getLogger(Cli.class); + + public static void main(String... args) throws Exception { + if (args.length == 0) { + logger.info("Usage:"); + logger.info(" Generate artifacts.xml in repo-folder:"); + logger.info(" validator-repo --target repo-folder"); + System.exit(0); + } + + Options options = new Options(); + options.addOption("t", "target", true, "Target"); + + CommandLineParser parser = new DefaultParser(); + CommandLine cmd = parser.parse(options, args); + + Repo.generateArtifacts(Paths.get(cmd.getOptionValue("target")), true); + } +} diff --git a/validator-repo/src/main/java/no/difi/vefa/validator/Repo.java b/validator-repo/src/main/java/no/difi/vefa/validator/Repo.java index 10dc156c..b78099a0 100644 --- a/validator-repo/src/main/java/no/difi/vefa/validator/Repo.java +++ b/validator-repo/src/main/java/no/difi/vefa/validator/Repo.java @@ -59,18 +59,6 @@ public class Repo { } } - /** - * Entry point when using cli. - * - * @param args Cli arguments. - * @throws Exception - */ - public static void main(String... args) throws Exception { - // Loop over input. Normally just one folder, but multiple is supported. - for (String directory : args) - generateArtifacts(Paths.get(directory), true); - } - /** * Generates list of artifacts for a given directory. *