From 76c47315987ea6a70a74a2c0d48cd39a6e9e0eee Mon Sep 17 00:00:00 2001 From: YuCheng Hu Date: Tue, 20 Nov 2018 14:11:22 -0500 Subject: [PATCH] =?UTF-8?q?=E5=88=A0=E9=99=A4=E4=B8=8D=E9=9C=80=E8=A6=81?= =?UTF-8?q?=E7=9A=84=E6=96=87=E4=BB=B6=E5=92=8C=E5=AF=BC=E5=85=A5=E6=96=87?= =?UTF-8?q?=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/ossez/lang/tutorial/Main.java | 91 +++++++++++++++++++ 1 file changed, 91 insertions(+) create mode 100644 src/main/java/com/ossez/lang/tutorial/Main.java diff --git a/src/main/java/com/ossez/lang/tutorial/Main.java b/src/main/java/com/ossez/lang/tutorial/Main.java new file mode 100644 index 0000000000..3e743ee941 --- /dev/null +++ b/src/main/java/com/ossez/lang/tutorial/Main.java @@ -0,0 +1,91 @@ +package com.ossez.lang.tutorial; + +import java.util.Properties; + +import org.apache.commons.cli.CommandLine; +import org.apache.commons.cli.CommandLineParser; +import org.apache.commons.cli.GnuParser; +import org.apache.commons.cli.Options; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class Main { + private static final Logger logger = LoggerFactory.getLogger(Main.class); + + private static Options options = new Options(); + private static Properties properties = new Properties(); + + private static CommandLine cl = null; + + private static boolean dryRun = false; + private static int limit = 0; + private static boolean force = false; + + public static void main(String[] args) { + + // get the idx feed properties file + Main.parseProperties(); + + // load console options + Main.parseCommandLine(args); + + logger.debug("Starting feeds..."); + System.out.println("starting feeds..."); + + // execute the feeds + Main.executeFeeds(); + + } + + /** + * Executes the feeds specified in the feeds.properties file. + */ + private static void executeFeeds() { + + } + + /** + * Parses the properties file to get a list of all feeds. + */ + private static void parseProperties() { + try { + // load the properties file + logger.debug("Parsing properties"); + Main.properties.load(Main.class.getClassLoader().getResourceAsStream("rets.properties")); + + // load the feeds + + } catch (Exception ex) { + ex.printStackTrace(); + logger.error("Could not parse feed properties", ex); + } + } + + /** + * Handles creation of console options. + */ + private static void parseCommandLine(String[] args) { + + // parse command line options + CommandLineParser parser = new GnuParser(); + + try { + Main.cl = parser.parse(Main.options, args); + + // get the dry run option + Main.dryRun = Main.cl.hasOption("d"); + logger.trace("Value of dryRun: " + dryRun); + + // get the limit option + // Main.limit = Utility.parseInt(Main.cl.getOptionValue("l", "0")); + logger.trace("Value of limit: " + Main.limit); + + // get the force option + Main.force = Main.cl.hasOption("u"); + logger.trace("Value of force: " + Main.force); + } catch (Exception ex) { + logger.error("An error ocurred parsing command line arguments", ex); + } + } +}