From 9d5fc4107f510417e233699165c795dcc60b7e68 Mon Sep 17 00:00:00 2001 From: Drew Short Date: Mon, 21 Apr 2014 20:11:59 -0500 Subject: [PATCH] Fixed an issue with the default logging. Also made some sort of basic change to the fxml for the main app. --- .../java/com/sothr/imagetools/AppCLI.java | 24 +++++++++++-------- .../java/com/sothr/imagetools/AppConfig.java | 2 +- src/main/resources/fxml/mainapp/MainApp.fxml | 2 +- 3 files changed, 16 insertions(+), 12 deletions(-) diff --git a/src/main/java/com/sothr/imagetools/AppCLI.java b/src/main/java/com/sothr/imagetools/AppCLI.java index 8b3c882..44e64fe 100644 --- a/src/main/java/com/sothr/imagetools/AppCLI.java +++ b/src/main/java/com/sothr/imagetools/AppCLI.java @@ -1,11 +1,7 @@ package com.sothr.imagetools; import com.sothr.imagetools.image.SimilarImages; -import org.apache.commons.cli.BasicParser; -import org.apache.commons.cli.CommandLine; -import org.apache.commons.cli.CommandLineParser; -import org.apache.commons.cli.Options; -import org.apache.commons.cli.Option; +import org.apache.commons.cli.*; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import scala.collection.immutable.List; @@ -17,16 +13,24 @@ class AppCLI { private static Logger logger; + private static final String HEADER = "Process images and search for duplicates and similar images heuristically"; + private static final String FOOTER = "Please report issues to..."; + public static void main(String[] args) { - AppConfig.configureApp(); - logger = LoggerFactory.getLogger(AppCLI.class); - logger.info("Started Image Tools CLI"); try { Options options = getOptions(); CommandLineParser parser = new BasicParser(); CommandLine cmd = parser.parse(options, args); - process(cmd); - AppConfig.shutdown(); + if (cmd.hasOption('h') || cmd.getOptions().length < 1 || cmd.getArgs().length > 0) { + HelpFormatter formatter = new HelpFormatter(); + formatter.printHelp("Image-Tools CLI", HEADER, options, FOOTER, true); + } else { + AppConfig.configureApp(); + logger = LoggerFactory.getLogger(AppCLI.class); + logger.info("Started Image Tools CLI"); + process(cmd); + AppConfig.shutdown(); + } System.exit(0); } catch (Exception ex) { logger.error("Unhandled exception in AppCLI",ex); diff --git a/src/main/java/com/sothr/imagetools/AppConfig.java b/src/main/java/com/sothr/imagetools/AppConfig.java index c78ed30..4b48a38 100644 --- a/src/main/java/com/sothr/imagetools/AppConfig.java +++ b/src/main/java/com/sothr/imagetools/AppConfig.java @@ -69,7 +69,7 @@ public class AppConfig { // Call context.reset() to clear any previous configuration, e.g. default // configuration. For multi-step configuration, omit calling context.reset(). context.reset(); - configurator.doConfigure(ResourceLoader.get().getResource("logback-minimum-config.xml")); + configurator.doConfigure(ResourceLoader.get().getResourceStream("logback-minimum-config.xml")); } catch (JoranException je) { // StatusPrinter will handle this } diff --git a/src/main/resources/fxml/mainapp/MainApp.fxml b/src/main/resources/fxml/mainapp/MainApp.fxml index 50d33f3..3156570 100644 --- a/src/main/resources/fxml/mainapp/MainApp.fxml +++ b/src/main/resources/fxml/mainapp/MainApp.fxml @@ -4,7 +4,7 @@ - +